diff options
author | Vika <vika@fireburn.ru> | 2021-05-17 09:21:54 +0300 |
---|---|---|
committer | Vika <vika@fireburn.ru> | 2021-05-17 09:21:54 +0300 |
commit | 9d90a72131153d53d751505aab883047cd0645c7 (patch) | |
tree | 6121ff37ed61cbec0e0e5a7f0e3d96e8b4afb3db /src/database/redis/mod.rs | |
parent | cc881705324a038b76c8e687f63f8a6972bbcad0 (diff) | |
download | kittybox-9d90a72131153d53d751505aab883047cd0645c7.tar.zst |
Added setting store per-user
Diffstat (limited to 'src/database/redis/mod.rs')
-rw-r--r-- | src/database/redis/mod.rs | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/database/redis/mod.rs b/src/database/redis/mod.rs index 4ab4ce0..352cece 100644 --- a/src/database/redis/mod.rs +++ b/src/database/redis/mod.rs @@ -82,6 +82,16 @@ fn filter_post(mut post: serde_json::Value, user: &'_ Option<String>) -> Option< #[async_trait] impl Storage for RedisStorage { + async fn get_setting<'a>(&self, setting: &'a str, user: &'a str) -> Result<String> { + let mut conn = self.redis.get().await?; + Ok(conn.hget::<String, &str, String>(format!("settings_{}", user), setting).await?) + } + + async fn set_setting<'a>(&self, setting: &'a str, user: &'a str, value: &'a str) -> Result<()> { + let mut conn = self.redis.get().await?; + Ok(conn.hset::<String, &str, &str, ()>(format!("settings_{}", user), setting, value).await?) + } + async fn delete_post<'a>(&self, url: &'a str) -> Result<()> { let mut conn = self.redis.get().await?; Ok(conn.hdel::<&str, &str, ()>("posts", url).await?) |