package cn.stylefeng.rest.config;
|
|
import cn.stylefeng.rest.config.cache.ObjectRedisCache;
|
import cn.stylefeng.roses.kernel.cache.api.CacheOperatorApi;
|
import cn.stylefeng.roses.kernel.cache.redis.util.CreateRedisTemplateUtil;
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Configuration;
|
import org.springframework.data.redis.connection.RedisConnectionFactory;
|
import org.springframework.data.redis.core.RedisTemplate;
|
|
/**
|
* 实体-Redis自动配置
|
*/
|
@Configuration
|
@ConditionalOnClass(name = "org.springframework.data.redis.connection.RedisConnectionFactory")
|
public class ObjectRedisAutoConfiguration {
|
|
@Bean
|
public CacheOperatorApi<Object> objectCacheOperatorApi(RedisConnectionFactory redisConnectionFactory) {
|
RedisTemplate<String, Object> redisTemplate = CreateRedisTemplateUtil.createObject(redisConnectionFactory);
|
return new ObjectRedisCache(redisTemplate);
|
}
|
|
}
|