org.macrocloud.kernel.jwt.config.JwtRedisConfiguration Maven / Gradle / Ivy
package org.macrocloud.kernel.jwt.config;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.annotation.Order;
import org.springframework.data.redis.cache.RedisCacheConfiguration;
import org.springframework.data.redis.cache.RedisCacheManager;
import org.springframework.data.redis.cache.RedisCacheWriter;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import java.time.Duration;
/**
* RedisTemplate 配置
*
*/
@Order
@EnableCaching
//@Configuration(proxyBeanMethods = false)
//@AutoConfigureAfter(RedisAutoConfiguration.class)
public class JwtRedisConfiguration {
@Bean("redisCacheManager")
@ConditionalOnMissingBean(name = "redisCacheManager")
public RedisCacheManager cacheManager(RedisConnectionFactory redisConnectionFactory) {
RedisCacheConfiguration redisCacheConfiguration = RedisCacheConfiguration.defaultCacheConfig()
.entryTtl(Duration.ofHours(1));
return RedisCacheManager.builder(RedisCacheWriter.nonLockingRedisCacheWriter(redisConnectionFactory))
.cacheDefaults(redisCacheConfiguration).build();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy