From 9d90a72131153d53d751505aab883047cd0645c7 Mon Sep 17 00:00:00 2001 From: Vika Date: Mon, 17 May 2021 09:21:54 +0300 Subject: Added setting store per-user --- src/database/redis/mod.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/database/redis') 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) -> Option< #[async_trait] impl Storage for RedisStorage { + async fn get_setting<'a>(&self, setting: &'a str, user: &'a str) -> Result { + let mut conn = self.redis.get().await?; + Ok(conn.hget::(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::(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?) -- cgit 1.4.1