mirror of
https://github.com/lukaszraczylo/graphql-monitoring-proxy.git
synced 2026-10-17 06:17:40 +00:00
fix(cache): make in-memory backend Close-able so Shutdown stops its cleaner
cache.Shutdown only called Close() on an io.Closer, which only the Redis backend (CacheWrapper) satisfied -- the in-memory Cache's Shutdown (cancels ctx, stopping its cleanupRoutine background ticker) was never reached, so that goroutine leaked until process exit (and with the default set-up, and whenever Redis is unreachable and EnableCache falls back to memory). Add Close() error to Cache (calls Shutdown, idempotent, leaves the cache usable) so cache.Shutdown handles both backends symmetrically. Update Shutdown doc; add test TestMemoryCacheClose_IdempotentAndStillUsable.
This commit is contained in:
Vendored
+1
-1
@@ -169,7 +169,7 @@ func EnableCache(cfg *CacheConfig) {
|
||||
}
|
||||
|
||||
// Shutdown closes the underlying cache client if it owns external resources
|
||||
// (the Redis connection pool). No-op for in-memory caches.
|
||||
// (the Redis connection pool, or the in-memory cleanup goroutine).
|
||||
func Shutdown() {
|
||||
if config != nil && config.Client != nil {
|
||||
if closer, ok := config.Client.(io.Closer); ok {
|
||||
|
||||
Reference in New Issue
Block a user