Skip to content

feat(secret): add Cache.Invalidate to drop a cached secret on rotation#97

Merged
jpugliesi merged 1 commit into
mainfrom
secret-cache-invalidate
Jun 25, 2026
Merged

feat(secret): add Cache.Invalidate to drop a cached secret on rotation#97
jpugliesi merged 1 commit into
mainfrom
secret-cache-invalidate

Conversation

@jpugliesi

@jpugliesi jpugliesi commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

secret.Cache caches GetSecretValue results under a TTL but exposes no way to evict an entry. A caller that rotates or deletes a secret through the underlying manager keeps reading the stale cached value until the TTL elapses — there's no way to force a re-read.

This adds Invalidate(name):

// drop the cached current-version entry after a write/delete
cache.Invalidate(name)
// next unversioned read re-fetches from the provider
v, _, _ := cache.GetSecretValue(ctx, name)

Behavior

  • Drops only the current-version entry (cacheKey{name}), which is the one that can go stale after a rotation/delete.
  • Version-pinned entries are left intact — a specific secret version is immutable, so its cached bytes never go stale.
  • One-liner over the existing cache.TTL.Drop; no new state.

secret.Cache had no way to evict an entry, so a caller that rotates or
deletes a secret through the underlying manager would keep reading the
stale cached value for the rest of the TTL. Invalidate(name) drops the
current-version entry, forcing the next unversioned GetSecretValue to
re-fetch. Version-pinned entries are left intact since a specific version
is immutable.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018SrxyoWmvc3fjrbdWrHogq
@jpugliesi jpugliesi self-assigned this Jun 25, 2026
@jpugliesi jpugliesi merged commit 9c7e6da into main Jun 25, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants