mirror of
https://github.com/actix/actix-extras.git
synced 2025-06-26 18:37:41 +02:00
chore: remove actix-redis crate (#408)
This commit is contained in:
@ -106,15 +106,6 @@ attached to your sessions. You can enable:
|
||||
actix-session = { version = "...", features = ["cookie-session"] }
|
||||
```
|
||||
|
||||
- a Redis-based backend via [`actix-redis`](https://docs.rs/actix-redis),
|
||||
[`RedisActorSessionStore`], using the `redis-actor-session` feature flag.
|
||||
|
||||
```toml
|
||||
[dependencies]
|
||||
# ...
|
||||
actix-session = { version = "...", features = ["redis-actor-session"] }
|
||||
```
|
||||
|
||||
- a Redis-based backend via [`redis-rs`](https://docs.rs/redis-rs), [`RedisSessionStore`], using
|
||||
the `redis-rs-session` feature flag.
|
||||
|
||||
|
@ -47,7 +47,7 @@ use crate::{
|
||||
/// # Examples
|
||||
/// ```no_run
|
||||
/// use actix_web::{web, App, HttpServer, HttpResponse, Error};
|
||||
/// use actix_session::{Session, SessionMiddleware, storage::RedisActorSessionStore};
|
||||
/// use actix_session::{Session, SessionMiddleware, storage::RedisSessionStore};
|
||||
/// use actix_web::cookie::Key;
|
||||
///
|
||||
/// // The secret key would usually be read from a configuration file/environment variables.
|
||||
@ -59,20 +59,20 @@ use crate::{
|
||||
/// #[actix_web::main]
|
||||
/// async fn main() -> std::io::Result<()> {
|
||||
/// let secret_key = get_secret_key();
|
||||
/// let redis_connection_string = "127.0.0.1:6379";
|
||||
/// HttpServer::new(move ||
|
||||
/// App::new()
|
||||
/// // Add session management to your application using Redis for session state storage
|
||||
/// .wrap(
|
||||
/// SessionMiddleware::new(
|
||||
/// RedisActorSessionStore::new(redis_connection_string),
|
||||
/// secret_key.clone()
|
||||
/// )
|
||||
/// )
|
||||
/// .default_service(web::to(|| HttpResponse::Ok())))
|
||||
/// .bind(("127.0.0.1", 8080))?
|
||||
/// .run()
|
||||
/// .await
|
||||
/// let storage = RedisSessionStore::new("127.0.0.1:6379").await.unwrap();
|
||||
///
|
||||
/// HttpServer::new(move || {
|
||||
/// App::new()
|
||||
/// // Add session management to your application using Redis as storage
|
||||
/// .wrap(SessionMiddleware::new(
|
||||
/// storage.clone(),
|
||||
/// secret_key.clone(),
|
||||
/// ))
|
||||
/// .default_service(web::to(|| HttpResponse::Ok()))
|
||||
/// })
|
||||
/// .bind(("127.0.0.1", 8080))?
|
||||
/// .run()
|
||||
/// .await
|
||||
/// }
|
||||
/// ```
|
||||
///
|
||||
@ -80,7 +80,7 @@ use crate::{
|
||||
///
|
||||
/// ```no_run
|
||||
/// use actix_web::{App, cookie::{Key, time}, Error, HttpResponse, HttpServer, web};
|
||||
/// use actix_session::{Session, SessionMiddleware, storage::RedisActorSessionStore};
|
||||
/// use actix_session::{Session, SessionMiddleware, storage::RedisSessionStore};
|
||||
/// use actix_session::config::PersistentSession;
|
||||
///
|
||||
/// // The secret key would usually be read from a configuration file/environment variables.
|
||||
@ -92,25 +92,23 @@ use crate::{
|
||||
/// #[actix_web::main]
|
||||
/// async fn main() -> std::io::Result<()> {
|
||||
/// let secret_key = get_secret_key();
|
||||
/// let redis_connection_string = "127.0.0.1:6379";
|
||||
/// HttpServer::new(move ||
|
||||
/// App::new()
|
||||
/// let storage = RedisSessionStore::new("127.0.0.1:6379").await.unwrap();
|
||||
///
|
||||
/// HttpServer::new(move || {
|
||||
/// App::new()
|
||||
/// // Customise session length!
|
||||
/// .wrap(
|
||||
/// SessionMiddleware::builder(
|
||||
/// RedisActorSessionStore::new(redis_connection_string),
|
||||
/// secret_key.clone()
|
||||
/// )
|
||||
/// .session_lifecycle(
|
||||
/// PersistentSession::default()
|
||||
/// .session_ttl(time::Duration::days(5))
|
||||
/// )
|
||||
/// .build(),
|
||||
/// SessionMiddleware::builder(storage.clone(), secret_key.clone())
|
||||
/// .session_lifecycle(
|
||||
/// PersistentSession::default().session_ttl(time::Duration::days(5)),
|
||||
/// )
|
||||
/// .build(),
|
||||
/// )
|
||||
/// .default_service(web::to(|| HttpResponse::Ok())))
|
||||
/// .bind(("127.0.0.1", 8080))?
|
||||
/// .run()
|
||||
/// .await
|
||||
/// .default_service(web::to(|| HttpResponse::Ok()))
|
||||
/// })
|
||||
/// .bind(("127.0.0.1", 8080))?
|
||||
/// .run()
|
||||
/// .await
|
||||
/// }
|
||||
/// ```
|
||||
#[derive(Clone)]
|
||||
|
@ -11,18 +11,13 @@ pub use self::{
|
||||
#[cfg(feature = "cookie-session")]
|
||||
mod cookie;
|
||||
|
||||
#[cfg(feature = "redis-actor-session")]
|
||||
mod redis_actor;
|
||||
|
||||
#[cfg(feature = "redis-rs-session")]
|
||||
mod redis_rs;
|
||||
|
||||
#[cfg(any(feature = "redis-actor-session", feature = "redis-rs-session"))]
|
||||
#[cfg(feature = "redis-rs-session")]
|
||||
mod utils;
|
||||
|
||||
#[cfg(feature = "cookie-session")]
|
||||
pub use cookie::CookieSessionStore;
|
||||
#[cfg(feature = "redis-actor-session")]
|
||||
pub use redis_actor::{RedisActorSessionStore, RedisActorSessionStoreBuilder};
|
||||
#[cfg(feature = "redis-rs-session")]
|
||||
pub use redis_rs::{RedisSessionStore, RedisSessionStoreBuilder};
|
||||
|
@ -120,9 +120,7 @@ impl RedisSessionStoreBuilder {
|
||||
self
|
||||
}
|
||||
|
||||
/// Finalise the builder and return a [`RedisActorSessionStore`] instance.
|
||||
///
|
||||
/// [`RedisActorSessionStore`]: crate::storage::RedisActorSessionStore
|
||||
/// Finalise the builder and return a [`RedisSessionStore`] instance.
|
||||
pub async fn build(self) -> Result<RedisSessionStore, anyhow::Error> {
|
||||
let client = ConnectionManager::new(redis::Client::open(self.connection_string)?).await?;
|
||||
Ok(RedisSessionStore {
|
||||
|
Reference in New Issue
Block a user