# sa-token-plugin-redis
**Repository Path**: bootx/sa-token-plugin-redis
## Basic Information
- **Project Name**: sa-token-plugin-redis
- **Description**: No description available
- **Primary Language**: Unknown
- **License**: Apache-2.0
- **Default Branch**: v1.25.0
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 1
- **Forks**: 2
- **Created**: 2021-08-03
- **Last Updated**: 2024-06-29
## Categories & Tags
**Categories**: Uncategorized
**Tags**: None
## README
# Sa-Token-Plugin-Redis插件
- 介绍
与官方实现思想不同,这个插件式聚合了官方多个`redis`插件包的功能,在原有功能基础上扩展了`FastJson` 序列化,后期将将支持`JRedis`和`Lucence`的配置切换。同时在配置方式上与官方插件有区别,通过继承`SaTokenRedisConfiguration` 后重写方法可以进行精细化的自定义配置。
- 添加pom依赖
```xml
com.gitee.bootx
sa-token-plugin-redis
${sa-token.plugin.version}
```
- yaml参数配置项
```yaml
sa-token:
plugins:
redis:
# 序列化方式, 支持JDK、JACKSON、FASTJSON三种
serialization: fastjson
# 是否开启独立redis存储
alone: true
# 独立redis存储配置,同redis配置项
alone-redis:
xxx: xxx
```
- 自定义配置
```java
/**
* 自定义配置
* @author xxm
* @date 2021/7/30
*/
@Configuration
@RequiredArgsConstructor
public class MySaTokenDaoRedisConfiguration extends SaTokenRedisConfiguration {
private final ObjectMapper objectMapper;
/**
* 自定义jdk序列化方式
*/
@Override
protected JdkSerializationRedisSerializer JdkRedisSerializer() {
return super.JdkRedisSerializer();
}
/**
* jackson序列化
*/
@Override
protected GenericJackson2JsonRedisSerializer jackson2JsonRedisSerializer() {
return super.jackson2JsonRedisSerializer();
}
/**
* 处理ObjectMapper对象,使用jackson序列化情况下, 可以重写这个方法进行自定义ObjectMapper,用于支持java8
* LocalDateTime等一些类
*/
@Override
protected ObjectMapper objectMapper() {
return super.objectMapper();
}
/**
* 自定义FastJson序列化
*/
@Override
protected GenericFastJsonRedisSerializer fastJsonRedisSerializer() {
return super.fastJsonRedisSerializer();
}
/**
* 扩展redis存储时的序列化方式,默认提供jdk、Jackson和FastJson三种
*/
@Override
public RedisSerializer