From 3779b77c25a5fbe4d209b18664a8a1e1fa6d6f63 Mon Sep 17 00:00:00 2001 From: Namekuji Date: Mon, 7 Aug 2023 04:01:54 -0400 Subject: [PATCH] Revert "clear cache at migration" This reverts commit aca0c47012325909c51b9b064b60b4ff6fcb66e5. --- .../backend/native-utils/migration/src/lib.rs | 2 -- .../src/m20230716_164152_clear_user_cache.rs | 29 ------------------- 2 files changed, 31 deletions(-) delete mode 100644 packages/backend/native-utils/migration/src/m20230716_164152_clear_user_cache.rs diff --git a/packages/backend/native-utils/migration/src/lib.rs b/packages/backend/native-utils/migration/src/lib.rs index 7a3d14c2eb..5ad23f1625 100644 --- a/packages/backend/native-utils/migration/src/lib.rs +++ b/packages/backend/native-utils/migration/src/lib.rs @@ -3,7 +3,6 @@ pub use sea_orm_migration::prelude::*; mod m20230531_180824_drop_reversi; mod m20230627_185451_index_note_url; mod m20230709_000510_move_antenna_to_cache; -mod m20230716_164152_clear_user_cache; pub struct Migrator; @@ -14,7 +13,6 @@ impl MigratorTrait for Migrator { Box::new(m20230531_180824_drop_reversi::Migration), Box::new(m20230627_185451_index_note_url::Migration), Box::new(m20230709_000510_move_antenna_to_cache::Migration), - Box::new(m20230716_164152_clear_user_cache::Migration), ] } } diff --git a/packages/backend/native-utils/migration/src/m20230716_164152_clear_user_cache.rs b/packages/backend/native-utils/migration/src/m20230716_164152_clear_user_cache.rs deleted file mode 100644 index 45352986f6..0000000000 --- a/packages/backend/native-utils/migration/src/m20230716_164152_clear_user_cache.rs +++ /dev/null @@ -1,29 +0,0 @@ -use redis::Commands; -use sea_orm_migration::prelude::*; -use std::env; - -#[derive(DeriveMigrationName)] -pub struct Migration; - -#[async_trait::async_trait] -impl MigrationTrait for Migration { - async fn up(&self, _manager: &SchemaManager) -> Result<(), DbErr> { - let cache_url = env::var("CACHE_URL").unwrap(); - let prefix = env::var("CACHE_PREFIX").unwrap(); - let client = redis::Client::open(cache_url).unwrap(); - let mut redis_conn = client.get_connection().unwrap(); - let keys: Vec = redis_conn - .keys(format!("{prefix}:cache:userById:*")).unwrap(); - - if !keys.is_empty() { - println!("Deleting {} keys from the cache server.", keys.len()); - redis_conn.del::<_, i32>(keys).unwrap(); - } - - Ok(()) - } - - async fn down(&self, _manager: &SchemaManager) -> Result<(), DbErr> { - Ok(()) - } -}