intrepid_model/caches/
cache_connection.rsuse super::{Cache, CacheRecord, CacheRepo, CacheRepoError, IntoCache};
#[derive(Clone, Default)]
pub struct CacheConnection<Repo> {
pub repo: Repo,
}
impl<Repo> CacheConnection<Repo>
where
Repo: CacheRepo,
{
pub fn new(repo: Repo) -> Self {
Self { repo }
}
pub async fn view(
&self,
uri: impl AsRef<str> + Send,
) -> Result<Cache<CacheRecord>, CacheRepoError> {
self.repo.get_memo(uri).await
}
pub async fn insert<CacheCandidate>(
&self,
record: CacheCandidate,
) -> Result<CacheRecord, CacheRepoError>
where
CacheCandidate: IntoCache + Send,
{
self.repo.set_memo(record).await
}
}