Get cached connection or fetch and cache it
(
session: &Arc<SessionState>,
db: &Arc<DbHandler>
)
| 157 | impl QueryExecutor { |
| 158 | /// Get cached connection or fetch and cache it |
| 159 | async fn get_or_cache_connection( |
| 160 | session: &Arc<SessionState>, |
| 161 | db: &Arc<DbHandler> |
| 162 | ) -> Option<Arc<parking_lot::Mutex<rusqlite::Connection>>> { |
| 163 | // First check if we have a cached connection |
| 164 | if let Some(cached) = session.get_cached_connection() { |
| 165 | // debug!("Using cached connection for session {}", session.id); |
| 166 | return Some(cached); |
| 167 | } |
| 168 | |
| 169 | // Try to get connection from manager and cache it |
| 170 | // debug!("Connection not cached for session {}, fetching from manager", session.id); |
| 171 | if let Some(conn_arc) = db.connection_manager().get_connection_arc(&session.id) { |
| 172 | session.cache_connection(conn_arc.clone()); |
| 173 | // debug!("Cached connection for session {}", session.id); |
| 174 | Some(conn_arc) |
| 175 | } else { |
| 176 | // debug!("No connection found for session {}", session.id); |
| 177 | None |
| 178 | } |
| 179 | } |
| 180 | pub async fn execute_query<T>( |
| 181 | framed: &mut Framed<T, crate::protocol::PostgresCodec>, |
| 182 | db: &Arc<DbHandler>, |
nothing calls this directly
no test coverage detected