- 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:
@@ -11,6 +11,7 @@ consul = []
|
||||
tokio = { version = "1.41.1", features = ["full"] }
|
||||
sqlx = { version = "0.7", features = ["postgres", "runtime-tokio-native-tls", "chrono"] }
|
||||
tonic = "0.12.3"
|
||||
chrono = { version = "0.4.39", features = ["serde"] }
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
dotenv = "0.15"
|
||||
tracing = "0.1"
|
||||
@@ -27,4 +28,4 @@ warp = "0.3.7"
|
||||
utils = { path = "../utils" }
|
||||
|
||||
[build-dependencies]
|
||||
tonic-build = "0.12.3"
|
||||
tonic-build = "0.12.3"
|
||||
|
||||
@@ -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