mirror of
https://github.com/containrrr/watchtower.git
synced 2025-12-16 07:00:13 +01:00
1.3 KiB
1.3 KiB
Proposal: Persistent / Distributed Token Cache
Summary
Introduce an optional pluggable token cache interface for registry auth tokens so deployments can opt for a shared cache (Redis, Memcached, or file-backed) across multiple Watchtower instances.
Motivation
- In multi-instance deployments, the in-memory token cache avoids redundant token requests only per instance. A shared cache reduces token endpoint load and synchronizes token usage across instances.
Proposal
- Define a
TokenCacheinterface (Get/Set/Delete) inpkg/registry/auth/cache_interface.go. - Keep the existing in-memory cache as the default implementation.
- Provide example Redis-backed implementation in
contrib/redis-token-cache/(optional).
Migration
- Add
TokenCacheinterface and adapter inpkg/registry/auth. - Wire
TokenCacheintoGetBearerHeaderto check the cache via the interface. - Add configuration options or environment variable to enable persistent cache and connection details.
Risks
- Operational complexity for configuration (credentials for Redis, etc.).
- Need to handle TTL semantics and clock skew.
References
- Current in-memory cache:
pkg/registry/auth/auth.go(tokenCache,getCachedToken,storeToken).