[][src]Struct actix_storage_redis::RedisBackend

pub struct RedisBackend { /* fields omitted */ }

An implementation of ExpiryStore based on redis using redis-rs async runtime

Example

use actix_storage::Storage;
use actix_storage_redis::{RedisBackend, ConnectionInfo, ConnectionAddr};
use actix_web::{App, HttpServer};

#[actix_web::main]
async fn main() -> std::io::Result<()> {
    const THREADS_NUMBER: usize = 4;
    let store = RedisBackend::connect_default();
    // OR
    let connection_info = ConnectionInfo {
        addr: ConnectionAddr::Tcp("127.0.0.1".to_string(), 1234).into(),
        db: 0,
        username: Some("god".to_string()),
        passwd: Some("bless".to_string()),
    };
    let store = RedisBackend::connect(connection_info).await.expect("Redis connection failed");

    let storage = Storage::build().expiry_store(store).finish();
    let server = HttpServer::new(move || {
        App::new()
            .data(storage.clone())
    });
    server.bind("localhost:5000")?.run().await
}

requires ["actor"] feature

Implementations

impl RedisBackend[src]

pub async fn connect(connection_info: ConnectionInfo) -> RedisResult<Self>[src]

Connect using the provided connection info

pub async fn connect_default() -> RedisResult<Self>[src]

Connect using the default redis port on local machine

Trait Implementations

impl Clone for RedisBackend[src]

impl Expiry for RedisBackend[src]

impl ExpiryStore for RedisBackend[src]

impl Store for RedisBackend[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T> Instrument for T[src]

impl<T> Instrument for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,