()
| 284 | * Use for graceful shutdown. |
| 285 | */ |
| 286 | export async function closeRedisConnection(): Promise<void> { |
| 287 | if (state.pingInterval) { |
| 288 | clearInterval(state.pingInterval) |
| 289 | state.pingInterval = null |
| 290 | } |
| 291 | |
| 292 | if (state.client) { |
| 293 | try { |
| 294 | await state.client.quit() |
| 295 | } catch (error) { |
| 296 | logger.error('Error closing Redis connection', { error }) |
| 297 | } finally { |
| 298 | state.client = null |
| 299 | } |
| 300 | } |
| 301 | } |
| 302 | |
| 303 | /** |
| 304 | * Reset all module-level state. Only intended for use in tests. |