From ad8080d9cfeb2d2b14ea250c708a016bd936c6a7 Mon Sep 17 00:00:00 2001 From: Astro Date: Mon, 26 Dec 2022 02:49:10 +0100 Subject: [PATCH] cave/store: let hosts expire --- cave/src/store.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/cave/src/store.rs b/cave/src/store.rs index 6a94b67..a6cabcc 100644 --- a/cave/src/store.rs +++ b/cave/src/store.rs @@ -13,6 +13,7 @@ use crate::{ const POST_EXPIRE: usize = 86400; const TAG_EXPIRE: u64 = 30 * 24; +const HOST_EXPIRE: usize = 30 * 86400; pub const TREND_POOL_SIZE: usize = 20; pub const IMAGES_PER_TAG: usize = 8; @@ -351,7 +352,12 @@ impl Store { } pub async fn save_host(&mut self, host: &str) -> Result<(), RedisError> { - redis::Cmd::set(format!("h:{}", host), "1") + let key = format!("h:{}", host); + redis::pipe() + .set(&key, "1") + .ignore() + .expire(&key, HOST_EXPIRE) + .ignore() .query_async::<_, ()>(self) .await }