From adb26330d27049ec4d3a335c4adb1b6afd5a05ae Mon Sep 17 00:00:00 2001 From: "Rodrigo Rodriguez (Pragmatismo)" Date: Sat, 21 Mar 2026 10:48:47 -0300 Subject: [PATCH] fix: Simple 50ms timeout for Redis connection --- src/basic/keywords/add_suggestion.rs | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/src/basic/keywords/add_suggestion.rs b/src/basic/keywords/add_suggestion.rs index a685e7c7..2f501ad7 100644 --- a/src/basic/keywords/add_suggestion.rs +++ b/src/basic/keywords/add_suggestion.rs @@ -1,24 +1,12 @@ use crate::core::shared::models::UserSession; use crate::core::shared::state::AppState; use log::{error, info, trace}; -use once_cell::sync::Lazy; use rhai::{Dynamic, Engine}; use serde_json::json; -use std::sync::{Arc, Mutex}; +use std::sync::Arc; use std::time::Duration; -static REDIS_CONN: Lazy>> = Lazy::new(|| Mutex::new(None)); - fn get_redis_connection(cache_client: &Arc) -> Option { - if let Ok(mut guard) = REDIS_CONN.lock() { - if let Some(ref mut conn) = *guard { - match redis::cmd("PING").query::(conn) { - Ok(_) => return Some(conn.clone()), - Err(_) => *guard = None, - } - } - } - let timeout = Duration::from_millis(50); cache_client.get_connection_with_timeout(timeout).ok() }