Skip to main content

DeboaCache

Trait DeboaCache 

Source
pub trait DeboaCache {
    // Required methods
    fn get(&self, key: &str) -> Option<String>;
    fn set(&self, key: &str, value: &str);
    fn delete(&self, key: &str);
}
Expand description

A trait defining the interface for cache implementations.

Implement this trait to provide custom caching behavior for HTTP responses. The cache is responsible for storing and retrieving responses based on their cache keys.

§Thread Safety

Implementations must be thread-safe as they may be accessed concurrently from multiple threads.

Required Methods§

Source

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

Get a value from the cache.

§Arguments
  • key - The key to get the value from.
§Returns
  • Option<String> - The value if it exists, None otherwise.
Source

fn set(&self, key: &str, value: &str)

Set a value in the cache.

§Arguments
  • key - The key to set the value for.
  • value - The value to set.
Source

fn delete(&self, key: &str)

Delete a value from the cache.

§Arguments
  • key - The key to delete the value for.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§