Skip to main content

Cache

Trait Cache 

Source
pub trait Cache {
    type Item;
    type Client;

    // Required methods
    async fn new() -> Self;
    async fn get_con(&self) -> Self::Client;
    async fn get(&self, id: Self::Item) -> Option<String>;
    async fn set(&self, id: Self::Item, content: Self::Item) -> bool;
    async fn update(&self, id: Self::Item, content: Self::Item) -> bool;
    async fn remove(&self, id: Self::Item) -> bool;
    async fn remove_starting_with(&self, id: Self::Item) -> bool;
    async fn incr(&self, id: Self::Item) -> bool;
    async fn decr(&self, id: Self::Item) -> bool;
}
Expand description

A simple cache “database”.

Required Associated Types§

Required Methods§

Source

async fn new() -> Self

Create a new Cache.

Source

async fn get_con(&self) -> Self::Client

Get a connection to the cache.

Source

async fn get(&self, id: Self::Item) -> Option<String>

Get a cache object by its identifier

§Arguments
  • id - String of the object’s id
Source

async fn set(&self, id: Self::Item, content: Self::Item) -> bool

Set a cache object by its identifier and content

§Arguments
  • id - String of the object’s id
  • content - String of the object’s content
Source

async fn update(&self, id: Self::Item, content: Self::Item) -> bool

Update a cache object by its identifier and content

§Arguments
  • id - String of the object’s id
  • content - String of the object’s content
Source

async fn remove(&self, id: Self::Item) -> bool

Remove a cache object by its identifier

§Arguments
  • id - String of the object’s id
Source

async fn remove_starting_with(&self, id: Self::Item) -> bool

Remove a cache object by its identifier(’s start)

§Arguments
  • id - String of the object’s id(’s start)
Source

async fn incr(&self, id: Self::Item) -> bool

Increment a cache object by its identifier

§Arguments
  • id - String of the object’s id
Source

async fn decr(&self, id: Self::Item) -> bool

Decrement a cache object by its identifier

§Arguments
  • id - String of the object’s id

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§