CacheBackend

Trait CacheBackend 

Source
pub trait CacheBackend: Send + Sync {
    // Required methods
    fn get(&self, key: &str) -> Option<u32>;
    fn set(&self, key: &str, value: u32, ttl: Duration) -> Result<(), String>;
    fn incr(&self, key: &str, amount: u32) -> Result<u32, String>;
}
Expand description

Trait to abstract any caching backend. This allows you to use Redis, in-memory caches, or any other backend.

Required Methods§

Source

fn get(&self, key: &str) -> Option<u32>

Retrieves the current count for the given key.

Source

fn set(&self, key: &str, value: u32, ttl: Duration) -> Result<(), String>

Sets the count for the given key with a time-to-live (TTL).

Source

fn incr(&self, key: &str, amount: u32) -> Result<u32, String>

Increments the count for the given key by amount and returns the new count.

Implementors§