about summary refs log tree commit diff
path: root/src/database/redis
diff options
context:
space:
mode:
Diffstat (limited to 'src/database/redis')
-rw-r--r--src/database/redis/mod.rs10
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?)