1use std::{future::Future, io::Result, time::Duration};
2
3use crate::Data;
4
5pub trait Storage: Send + Sync {
7 fn get(&self, key: &str) -> impl Future<Output = Result<Option<Data>>> + Send;
9
10 fn set(&self, key: &str, val: Data, exp: &Duration) -> impl Future<Output = Result<()>> + Send;
12
13 fn remove(&self, key: &str) -> impl Future<Output = Result<()>> + Send;
15
16 fn reset(&self) -> impl Future<Output = Result<()>> + Send {
18 async { Ok(()) }
19 }
20
21 fn close(&self) -> impl Future<Output = Result<()>> + Send {
23 async { Ok(()) }
24 }
25}