package com.tzld.piaoquan.recommend.server.service;

import com.tzld.piaoquan.recommend.server.repository.WxVideoStatusRepository;
import com.tzld.piaoquan.recommend.server.util.SimilarityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.core.annotation.Order;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;

/**
 * @author dyp
 */
@Component
@Order(1)
public class WarmUpService {
    @Autowired
    @Qualifier("redisTemplate")
    private RedisTemplate<String, String> redisTemplate;
    @Autowired
    @Qualifier("featureRedisTemplate")
    private RedisTemplate<String, String> featureRedisTemplate;
    @Autowired
    @Qualifier("longVideoRedisTemplate")
    private RedisTemplate<String, String> longVideoRedisTemplate;
    @Autowired
    private WxVideoStatusRepository wxVideoStatusRepository;

    @PostConstruct
    public void warmup() {
        redisTemplate.opsForValue().get("");
        featureRedisTemplate.opsForValue().get("");
        longVideoRedisTemplate.opsForValue().get("");
        com.tzld.piaoquan.recommend.server.service.score.ScorerUtils.warmUp();
        wxVideoStatusRepository.count();
        SimilarityUtils.init();

    }
}
