mocra_core/cacheable/
dag_store.rs1use std::time::Duration;
9
10use async_trait::async_trait;
11use mocra_dag::DagStore;
12
13use super::CacheService;
14
15#[async_trait]
16impl DagStore for CacheService {
17 async fn get(&self, key: &str) -> Result<Option<Vec<u8>>, String> {
18 CacheService::get(self, key)
19 .await
20 .map_err(|e| e.to_string())
21 }
22 async fn set(&self, key: &str, value: &[u8], ttl: Option<Duration>) -> Result<(), String> {
23 CacheService::set(self, key, value, ttl)
24 .await
25 .map_err(|e| e.to_string())
26 }
27 async fn del(&self, key: &str) -> Result<(), String> {
28 CacheService::del(self, key)
29 .await
30 .map_err(|e| e.to_string())
31 }
32 async fn incr(&self, key: &str, delta: i64) -> Result<i64, String> {
33 CacheService::incr(self, key, delta)
34 .await
35 .map_err(|e| e.to_string())
36 }
37}