当前位置:网站首页>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之命令注入篇
- Right mouse button customization
- AcWing 1148. 秘密的牛奶运输 题解(最小生成树)
- First experience of JSON learning - the third-party jar package realizes bean, list and map to create JSON format
- Let's see how to realize BP neural network in Matlab toolbox
- JS how to quickly create an array with length n
- HDU 4661 message passing (wood DP & amp; Combinatorics)
- ROS学习(21)机器人SLAM功能包——orbslam的安装与测试
- MySQL execution process and sequence
- Set WordPress pseudo static connection (no pagoda)
猜你喜欢

centos8安裝mysql報錯:The GPG keys listed for the “MySQL 8.0 Community Server“ repository are already ins
![[unique] what is the [chain storage structure]?](/img/cd/be18c65b9d7faccc3c9b18e3b2ce8e.png)
[unique] what is the [chain storage structure]?

开发中对集合里面的数据根据属性进行合并数量时犯的错误

ROS learning (22) TF transformation

Cat recycling bin

Errors made in the development of merging the quantity of data in the set according to attributes

ROS学习(24)plugin插件

Baidu flying general BMN timing action positioning framework | data preparation and training guide (Part 2)

设置Wordpress伪静态连接(无宝塔)

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
随机推荐
Batch delete data in SQL - set in entity
糊涂工具类(hutool)post请求设置body参数为json数据
Date processing tool class dateutils (tool class 1)
DS-5/RVDS4.0变量初始化错误
长按按钮执行函数
Related programming problems of string
Golang foundation - data type
Modify the system time of Px4 flight control
hdu 4661 Message Passing(木DP&amp;组合数学)
ROS learning (25) rviz plugin
The GPG keys listed for the "MySQL 8.0 community server" repository are already ins
使用nodejs完成判断哪些项目打包+发版
Public key \ private SSH avoid password login
2022 system integration project management engineer examination knowledge point: Mobile Internet
Today's question -2022/7/4 modify string reference type variables in lambda body
Curl command
mysqlbackup 还原特定的表
AcWing 345. 牛站 题解(floyd的性质、倍增)
AcWing 1148. 秘密的牛奶运输 题解(最小生成树)
刨析《C语言》【进阶】付费知识【二】