package com.tanpu.community.manager;
import com.tanpu.community.service.RedisService;
import com.tanpu.community.service.VisitSummaryService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;
@Slf4j
@Service
@Configuration
public class ConJobManager {
@Autowired
private VisitSummaryService visitSummaryService;
@Autowired
private RedisService redisService;
/**
* 定时统计 话题 访问数据,并刷到redis
*/
@Scheduled(cron = "*/10 * * * * ?")
public void topicVisitorStats() {
String topicId = "123";
Integer detailVisitTimes = visitSummaryService.queryTopicDetailVisit(topicId);
redisService.set("topicVisitorStats", detailVisitTimes);
}
}
-
张辰 authored3893149c