- add: database schema

- add: ability to delete keys from RedisCache
- update: docker compose to init the database with the schema
This commit is contained in:
2024-12-17 01:54:46 -05:00
parent 277d25a820
commit 267422adb4
4 changed files with 125 additions and 2 deletions

View File

@@ -16,7 +16,8 @@ pub trait Cache {
&self,
key: &String,
) -> Result<Option<T>, redis::RedisError>;
async fn delete(&mut self, key: &str) -> redis::RedisResult<()>;
}
pub struct RedisCache {
@@ -77,4 +78,16 @@ impl Cache for RedisCache {
Ok(None)
}
}
async fn delete(&mut self, key: &str) -> redis::RedisResult<()> {
let mut conn = self.pool.get().await
.map_err(|err| {
redis::RedisError::from((
redis::ErrorKind::IoError,
"Failed to get Redis connection",
format!("{:?}", err),
))
})?;
conn.del(key).await
}
}