VideoCountServiceImpl.java 1.1 KB
Newer Older
喷火的神灵's avatar
喷火的神灵 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
package cn.tedu.youbiliprojectbackend.common.cacheUtils.count.video.service.impl;

import cn.tedu.youbiliprojectbackend.common.cacheUtils.count.video.dao.cache.VideoCountCache;
import cn.tedu.youbiliprojectbackend.common.cacheUtils.count.video.dao.persist.repository.VideoCountRepositroy;
import cn.tedu.youbiliprojectbackend.common.cacheUtils.count.video.service.VideoCountService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import org.springframework.stereotype.Service;

@Slf4j
@Service
public class VideoCountServiceImpl implements VideoCountService {

    @Autowired
    VideoCountRepositroy videoCountRepositroy;
    @Autowired
    VideoCountCache videoCountCache;

    /**
     * 当项目启动时 先清除videoCount字段 再保存
     */
    @Override
    public void SaveCacheVideoCount() {
        log.debug("开始向缓存之中写入数据!");
        videoCountCache.deleteAll();
        videoCountCache.save(videoCountRepositroy.videoCacheCount());
    }
}