13 lines
365 B
Rust
13 lines
365 B
Rust
//! Redis 连接管理
|
|
|
|
use redis::aio::ConnectionManager;
|
|
use redis::Client;
|
|
|
|
/// 建立 Redis 连接管理器
|
|
pub async fn init_connection(redis_url: &str) -> Result<ConnectionManager, redis::RedisError> {
|
|
let client = Client::open(redis_url)?;
|
|
let conn = ConnectionManager::new(client).await?;
|
|
tracing::info!("Redis 连接已建立");
|
|
Ok(conn)
|
|
}
|