sa-token-storage-redis
Redis storage implementation for sa-token-rust.
Features
- 🚀 High Performance: Redis-based storage with connection pooling
- 🔐 Password Support: Supports Redis authentication
- ⚙️ Flexible Configuration: Multiple initialization methods
- 🎯 Production Ready: Suitable for distributed deployments
Installation
[]
= "0.1.2"
= { = "1", = ["full"] }
Quick Start
Method 1: Redis URL (Simplest)
use RedisStorage;
let storage = new.await?;
Method 2: RedisConfig (Structured)
use ;
let config = RedisConfig ;
let storage = from_config.await?;
Method 3: Builder Pattern (Most Flexible)
use RedisStorage;
let storage = builder
.host
.port
.password
.database
.key_prefix
.build
.await?;
Complete Example
use RedisStorage;
use SaTokenState;
use Arc;
async
Configuration
| Field | Type | Default | Description |
|---|---|---|---|
| host | String | localhost | Redis server address |
| port | u16 | 6379 | Redis port |
| password | Option<String> | None | Redis password |
| database | u8 | 0 | Database number (0-15) |
| pool_size | u32 | 10 | Connection pool size |
Author
金书记
License
Licensed under either of:
- Apache License, Version 2.0
- MIT License