fix(cache): harden cache backends, resilience, recovery, and transports

- RESP -ERR no longer closes healthy conn / aborts batch; global cap replacement-aware
- global health-check pass serialized (latent data race); MemoryMonitor via ResourceManager
- token-exchange retry, open-circuit rejections counted as failures
- TLS-posture matching transport reuse (no silent InsecureSkipVerify handoff)
This commit is contained in:
2026-08-14 16:16:51 +01:00
parent 8640451877
commit 4d23d618f5
49 changed files with 2318 additions and 181 deletions
+15
View File
@@ -95,7 +95,15 @@ func (r *RedisBackend) Set(ctx context.Context, key string, value []byte, ttl ti
return ErrBackendClosed
}
// A NEGATIVE TTL means "already expired" (the stack's convention for a
// value whose validity has passed). Previously ttl<=0 fell through to a
// bare SET with no expiry, silently making the entry permanent. Zero here
// is the documented "no expiry" contract (see SetManyNoTTL), so only
// strictly-negative TTLs are skipped.
prefixedKey := r.prefixKey(key)
if ttl < 0 {
return nil
}
// Execute with retry logic
return r.executeWithRetry(ctx, func(conn *RedisConn) error {
@@ -450,6 +458,13 @@ func (r *RedisBackend) SetMany(ctx context.Context, items map[string][]byte, ttl
return nil
}
if ttl < 0 {
// Already-expired TTL: nothing to persist (see Set's guard). Avoids
// creating permanent entries for past-dated values via the multi path.
// Zero retains the "no expiry" contract (see SetManyNoTTL).
return nil
}
// For single items, use regular Set
if len(items) == 1 {
for key, value := range items {