您的位置:首页 > 房产 > 建筑 > 中文网站开发_综合b2b电子商务网站有哪些_自媒体代运营_网络营销方案策划

中文网站开发_综合b2b电子商务网站有哪些_自媒体代运营_网络营销方案策划

2025/4/27 11:13:29 来源:https://blog.csdn.net/Anenan/article/details/147513261  浏览:    关键词:中文网站开发_综合b2b电子商务网站有哪些_自媒体代运营_网络营销方案策划
中文网站开发_综合b2b电子商务网站有哪些_自媒体代运营_网络营销方案策划
@Configuration
public class ChargeRedisConfig {@Value("${spring.redis.host}")private String host;@Value("${spring.redis.port}")private int port;@Value("${spring.redis.password}")private String password;@Value("${spring.redis.chargeDatabase:1}")private int chargeDatabase;@Bean("chargeRedisTemplate")public RedisTemplate<String, Object> chargeRedisTemplate() {RedisStandaloneConfiguration redisStandaloneConfiguration = new RedisStandaloneConfiguration();redisStandaloneConfiguration.setHostName(host);redisStandaloneConfiguration.setPort(port);redisStandaloneConfiguration.setPassword(password);redisStandaloneConfiguration.setDatabase(chargeDatabase);LettuceConnectionFactory factory = new LettuceConnectionFactory(redisStandaloneConfiguration);factory.afterPropertiesSet();RedisTemplate<String, Object> template = new RedisTemplate<>();template.setConnectionFactory(factory);template.setKeySerializer(new StringRedisSerializer());template.setValueSerializer(new GenericFastJsonRedisSerializer());template.setHashKeySerializer(new StringRedisSerializer());template.setHashValueSerializer(new GenericFastJsonRedisSerializer());return template;}
}
spring:redis:enabled: truetype: 1host: 192.168.1.1port: 6379password: 123456timeout: 10000# 默认databasedatabase: 1# 收费databasechargeDatabase: 2ttl: 60lettuce:pool:max-active: 500max-idle: 10min-idle: 2max-wait: 3000shutdown-timeout: 10000command-timeout: 60000jackson:date-format: yyyy-MM-dd HH:mm:sstime-zone: GMT+8

使用

@Resource
private RedisTemplate<String, Object> chargeRedisTemplate;String key = "123";
Object o = chargeRedisTemplate.opsForValue().get(key);

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com