当前位置:网站首页>Redis configuration class redisconfig
Redis configuration class redisconfig
2022-07-07 01:56:00 【Novice Zhang~】
package com.menglar.soap.item.common.config;
import com.alibaba.fastjson.support.spring.GenericFastJsonRedisSerializer;
import com.menglar.soap.item.common.listener.KeyExpiredListener;
import org.springframework.beans.factory.annotation.Autowired;
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;
import org.springframework.data.redis.listener.RedisMessageListenerContainer;
import org.springframework.data.redis.serializer.GenericToStringSerializer;
/** * @program: soap-item_v2 * @description: redis Configuration class * @author: ZhangRiTian * @create: 2021-10-25 09:24 */
@Configuration
public class RedisConfig {
@Autowired
private RedisConnectionFactory redisConnectionFactory;
/** * Listener connection factory class */
@Bean
public RedisMessageListenerContainer redisMessageListenerContainer() {
RedisMessageListenerContainer redisMessageListenerContainer = new RedisMessageListenerContainer();
redisMessageListenerContainer.setConnectionFactory(redisConnectionFactory);
return redisMessageListenerContainer;
}
/** * Monitor */
@Bean
public KeyExpiredListener keyExpiredListener() {
return new KeyExpiredListener(this.redisMessageListenerContainer());
}
@Bean
public RedisTemplate<Object, Object> redisTemplate(RedisConnectionFactory redisConnectionFactory) {
RedisTemplate<Object, Object> redisTemplate = new RedisTemplate<>();
redisTemplate.setConnectionFactory(redisConnectionFactory);
// Use GenericFastJsonRedisSerializer Replace default serialization
GenericFastJsonRedisSerializer genericFastJsonRedisSerializer = new GenericFastJsonRedisSerializer();
// Set up key and value Serialization rules
redisTemplate.setKeySerializer(new GenericToStringSerializer<>(Object.class));
redisTemplate.setValueSerializer(genericFastJsonRedisSerializer);
// Set up hashKey and hashValue Serialization rules
redisTemplate.setHashKeySerializer(new GenericToStringSerializer<>(Object.class));
redisTemplate.setHashValueSerializer(genericFastJsonRedisSerializer);
// Set up supporting things
redisTemplate.setEnableTransactionSupport(true);
redisTemplate.afterPropertiesSet();
return redisTemplate;
}
}
边栏推荐
- CISP-PTE之命令注入篇
- Image watermarking, scaling and conversion of an input stream
- ROS学习(十九)机器人SLAM功能包——cartographer
- 百度飞将BMN时序动作定位框架 | 数据准备与训练指南 (上)
- IDEA常用的快捷键
- 公钥\私人 ssh避password登陆
- AcWing 361. Sightseeing cow problem solution (SPFA seeking positive ring)
- 长按按钮执行函数
- The cradle of eternity
- 【唯一】的“万字配图“ | 讲透【链式存储结构】是什么?
猜你喜欢

【唯一】的“万字配图“ | 讲透【链式存储结构】是什么?

Can't you understand the code of linked list in C language? An article allows you to grasp the secondary pointer and deeply understand the various forms of parameter passing in the function parameter

How did partydao turn a tweet into a $200million product Dao in one year

centos8安裝mysql報錯:The GPG keys listed for the “MySQL 8.0 Community Server“ repository are already ins

蓝桥杯2022年第十三届省赛真题-积木画

Blue Bridge Cup 2022 13th provincial competition real topic - block painting

ROS学习(二十)机器人SLAM功能包——rgbdslam的安装与测试

AcWing 345. Cattle station solution (nature and multiplication of Floyd)

ROS learning (24) plugin

Introduction to microservice architecture
随机推荐
ROS learning (21) robot slam function package -- installation and testing of orbslam
AcWing 1141. 局域网 题解(kruskalkruskal 求最小生成树)
场景实践:基于函数计算快速搭建Wordpress博客系统
Shortcut keys commonly used in idea
Threadlocalutils (tool class IV)
制作带照明的DIY焊接排烟器
Gin 入门实战
The use of video in the wiper component causes full screen dislocation
ROS学习(21)机器人SLAM功能包——orbslam的安装与测试
Can't you understand the code of linked list in C language? An article allows you to grasp the secondary pointer and deeply understand the various forms of parameter passing in the function parameter
C语言关于链表的代码看不懂?一篇文章让你拿捏二级指针并深入理解函数参数列表中传参的多种形式
使用nodejs完成判断哪些项目打包+发版
Centros 8 installation MySQL Error: The gpg Keys listed for the "MySQL 8.0 Community Server" repository are already ins
AcWing 361. 观光奶牛 题解(spfa求正环)
CISP-PTE之命令注入篇
AcWing 1142. 繁忙的都市 题解(最小生成树)
Telnet,SSH1,SSH2,Telnet/SSL,Rlogin,Serial,TAPI,RAW
百度飞将BMN时序动作定位框架 | 数据准备与训练指南 (下)
Batch delete data in SQL - set in entity
糊涂工具类(hutool)post请求设置body参数为json数据