- 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:
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user