1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
use async_trait::async_trait;
use crate::errors::{Define, Result};
pub enum CacheError {
Internal,
}
impl Define for CacheError {
fn define(&self) -> &str {
match self {
CacheError::Internal => "cache.internal",
}
}
}
#[async_trait]
pub trait Cache<K, V> {
async fn get(&self, k: &K) -> Result<Option<V>>;
async fn set(&self, k: K, v: V) -> Result<()>;
async fn delete(&self, k: &K) -> Result<()>;
}