pub struct CacheService { /* private fields */ }Implementations§
Source§impl CacheService
impl CacheService
Sourcepub fn new(
namespace: String,
default_ttl: Option<Duration>,
compression_threshold: Option<usize>,
) -> Self
pub fn new( namespace: String, default_ttl: Option<Duration>, compression_threshold: Option<usize>, ) -> Self
Builds an in-process (local in-memory) cache service.
The cache backend is always the in-process LocalBackend.
The compression_threshold parameter is kept for compatibility with existing callers, but
the local backend performs no compression.
pub async fn set_nx( &self, key: &str, value: &[u8], ttl: Option<Duration>, ) -> Result<bool, CacheError>
pub fn namespace(&self) -> &str
pub async fn zadd( &self, key: &str, score: f64, member: &[u8], ) -> Result<i64, CacheError>
pub async fn zrangebyscore( &self, key: &str, min: f64, max: f64, ) -> Result<Vec<Vec<u8>>, CacheError>
pub async fn zremrangebyscore( &self, key: &str, min: f64, max: f64, ) -> Result<i64, CacheError>
pub async fn set_nx_batch( &self, keys: &[&str], value: &[u8], ttl: Option<Duration>, ) -> Result<Vec<bool>, CacheError>
pub async fn mget( &self, keys: &[&str], ) -> Result<Vec<Option<Vec<u8>>>, CacheError>
pub async fn incr(&self, key: &str, delta: i64) -> Result<i64, CacheError>
pub async fn set( &self, key: &str, value: &[u8], ttl: Option<Duration>, ) -> Result<(), CacheError>
pub async fn del(&self, key: &str) -> Result<(), CacheError>
pub async fn del_batch(&self, keys: &[&str]) -> Result<u64, CacheError>
pub async fn keys(&self, pattern: &str) -> Result<Vec<String>, CacheError>
pub async fn keys_with_limit( &self, pattern: &str, limit: usize, ) -> Result<Vec<String>, CacheError>
pub async fn get(&self, key: &str) -> Result<Option<Vec<u8>>, CacheError>
pub async fn ping(&self) -> Result<(), CacheError>
pub fn default_ttl(&self) -> Option<Duration>
Trait Implementations§
Source§impl DagStore for CacheService
impl DagStore for CacheService
fn get<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<Vec<u8>>, String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn set<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
key: &'life1 str,
value: &'life2 [u8],
ttl: Option<Duration>,
) -> Pin<Box<dyn Future<Output = Result<(), String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn del<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<(), String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn incr<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str,
delta: i64,
) -> Pin<Box<dyn Future<Output = Result<i64, String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Auto Trait Implementations§
impl !RefUnwindSafe for CacheService
impl !UnwindSafe for CacheService
impl Freeze for CacheService
impl Send for CacheService
impl Sync for CacheService
impl Unpin for CacheService
impl UnsafeUnpin for CacheService
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more