[−][src]Struct actix_storage_redis::RedisBackend
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]
fn clone(&self) -> RedisBackend
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Expiry for RedisBackend
[src]
fn persist<'life0, 'async_trait>(
&'life0 self,
key: Arc<[u8]>
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: 'async_trait,
[src]
&'life0 self,
key: Arc<[u8]>
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: 'async_trait,
fn expiry<'life0, 'async_trait>(
&'life0 self,
key: Arc<[u8]>
) -> Pin<Box<dyn Future<Output = Result<Option<Duration>>> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: 'async_trait,
[src]
&'life0 self,
key: Arc<[u8]>
) -> Pin<Box<dyn Future<Output = Result<Option<Duration>>> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: 'async_trait,
fn expire<'life0, 'async_trait>(
&'life0 self,
key: Arc<[u8]>,
expire_in: Duration
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: 'async_trait,
[src]
&'life0 self,
key: Arc<[u8]>,
expire_in: Duration
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: 'async_trait,
#[must_use]fn extend<'life0, 'async_trait>(
&'life0 self,
key: Arc<[u8]>,
expire_in: Duration
) -> Pin<Box<dyn Future<Output = Result<(), StorageError>> + 'async_trait + Send>> where
'life0: 'async_trait,
Self: 'async_trait,
[src]
&'life0 self,
key: Arc<[u8]>,
expire_in: Duration
) -> Pin<Box<dyn Future<Output = Result<(), StorageError>> + 'async_trait + Send>> where
'life0: 'async_trait,
Self: 'async_trait,
#[must_use]fn set_called<'life0, 'async_trait>(
&'life0 self,
key: Arc<[u8]>
) -> Pin<Box<dyn Future<Output = ()> + 'async_trait + Send>> where
'life0: 'async_trait,
Self: 'async_trait,
[src]
&'life0 self,
key: Arc<[u8]>
) -> Pin<Box<dyn Future<Output = ()> + 'async_trait + Send>> where
'life0: 'async_trait,
Self: 'async_trait,
impl ExpiryStore for RedisBackend
[src]
fn set_expiring<'life0, 'async_trait>(
&'life0 self,
key: Arc<[u8]>,
value: Arc<[u8]>,
expire_in: Duration
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: 'async_trait,
[src]
&'life0 self,
key: Arc<[u8]>,
value: Arc<[u8]>,
expire_in: Duration
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: 'async_trait,
#[must_use]fn get_expiring<'life0, 'async_trait>(
&'life0 self,
key: Arc<[u8]>
) -> Pin<Box<dyn Future<Output = Result<Option<(Arc<[u8]>, Option<Duration>)>, StorageError>> + 'async_trait + Send>> where
'life0: 'async_trait,
Self: 'async_trait,
[src]
&'life0 self,
key: Arc<[u8]>
) -> Pin<Box<dyn Future<Output = Result<Option<(Arc<[u8]>, Option<Duration>)>, StorageError>> + 'async_trait + Send>> where
'life0: 'async_trait,
Self: 'async_trait,
impl Store for RedisBackend
[src]
fn set<'life0, 'async_trait>(
&'life0 self,
key: Arc<[u8]>,
value: Arc<[u8]>
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: 'async_trait,
[src]
&'life0 self,
key: Arc<[u8]>,
value: Arc<[u8]>
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: 'async_trait,
fn get<'life0, 'async_trait>(
&'life0 self,
key: Arc<[u8]>
) -> Pin<Box<dyn Future<Output = Result<Option<Arc<[u8]>>>> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: 'async_trait,
[src]
&'life0 self,
key: Arc<[u8]>
) -> Pin<Box<dyn Future<Output = Result<Option<Arc<[u8]>>>> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: 'async_trait,
fn delete<'life0, 'async_trait>(
&'life0 self,
key: Arc<[u8]>
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: 'async_trait,
[src]
&'life0 self,
key: Arc<[u8]>
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: 'async_trait,
fn contains_key<'life0, 'async_trait>(
&'life0 self,
key: Arc<[u8]>
) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: 'async_trait,
[src]
&'life0 self,
key: Arc<[u8]>
) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: 'async_trait,
Auto Trait Implementations
impl !RefUnwindSafe for RedisBackend
impl Send for RedisBackend
impl Sync for RedisBackend
impl Unpin for RedisBackend
impl !UnwindSafe for RedisBackend
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T> Instrument for T
[src]
fn instrument(self, span: Span) -> Instrumented<Self>
[src]
fn in_current_span(self) -> Instrumented<Self>
[src]
impl<T> Instrument for T
[src]
fn instrument(self, span: Span) -> Instrumented<Self>
[src]
fn in_current_span(self) -> Instrumented<Self>
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,