| | |
| | | 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.redisson.Redisson; |
| | | import org.redisson.api.RedissonClient; |
| | | import org.redisson.config.Config; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; |
| | | import org.springframework.context.annotation.Bean; |
| | | import org.springframework.context.annotation.Configuration; |
| | |
| | | return new ObjectRedisCache(redisTemplate); |
| | | } |
| | | |
| | | @Value("${spring.redis.host}") |
| | | private String host; |
| | | @Value("${spring.redis.port}") |
| | | private int port; |
| | | |
| | | @Value("${spring.redis.password}") |
| | | private String password; |
| | | |
| | | @Value("${spring.redis.database}") |
| | | private int database; |
| | | |
| | | @Bean |
| | | public RedissonClient redissonClient(){ |
| | | Config config = new Config(); |
| | | config.useSingleServer().setAddress("redis://"+host+":"+port) |
| | | .setPassword(password) |
| | | .setDatabase(database); |
| | | return Redisson.create(config); |
| | | } |
| | | |
| | | } |