sa-token/sa-token-plugin/sa-token-redisx/README.md

36 lines
735 B
Markdown
Raw Permalink Normal View History

2022-05-10 13:47:49 +08:00
sa-token-redisx 是中立的扩展。可任何应用开发框架下使用springboot, solon, jfinal 等..
2023-01-14 09:33:25 +08:00
2022-05-10 13:47:49 +08:00
### 使用示例
#### 1.配置
```yaml
sa-token: #名字可以随意取
2022-05-10 13:47:49 +08:00
redis:
server: "localhost:6379"
password: 123456
db: 1
# serializer: "org.noear.redisx.utils.SerializerJson" #指定自定义序列化实现(默认为 SerializerDefault
2022-05-10 13:47:49 +08:00
```
#### 2.代码
**注入风格**
```java
@Configuration
public class Config {
@Bean
public SaTokenDao saTokenDaoInit(@Inject("${sa-token.redis}") SaTokenDaoOfRedis saTokenDao) {
2022-05-10 13:47:49 +08:00
return saTokenDao;
}
}
```
**手动风格**
```java
SaTokenDaoOfRedis saTokenDao = new SaTokenDaoOfRedis(props);
SaManager.setSaTokenDao(saTokenDao);
```