Skip to content

Add configurable identity cache TTL (refresh stale names/avatars)#79

Closed
Frodotus wants to merge 1 commit into
gammons:mainfrom
Frodotus:feat/identity-ttl
Closed

Add configurable identity cache TTL (refresh stale names/avatars)#79
Frodotus wants to merge 1 commit into
gammons:mainfrom
Frodotus:feat/identity-ttl

Conversation

@Frodotus

@Frodotus Frodotus commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

Closes #78.

What

Adds a configurable freshness window so resolved user/bot identities (name + avatar) are re-fetched once stale, instead of being cached forever.

[cache]
identity_ttl_days = 7   # 0 disables refresh (current behavior)

How

  • CacheConfig.IdentityTTLDays (default 7); 0 keeps the historical "cache forever".
  • UpsertUser stamps updated_at (when the caller leaves it unset) so freshness is tracked.
  • userResolver gains a TTL: Request/RequestBot skip only when cached and fresh; past the TTL they re-fetch (users.info / bots.info) and pick up renames + new avatars.
  • Real avatar refresh: avatar.Cache.Invalidate + image.Fetcher.Delete bust the never-cleared inflight gate, the cached render, and the fetcher's stable avatar-<id> entry, so a changed URL actually re-downloads.

Testing

go test ./... passes. Added TestUserResolverFresh (TTL decision incl. 0=off and unstamped=stale) and TestUpsertUserStampsUpdatedAt (stamping + explicit value respected).

@Frodotus Frodotus marked this pull request as ready for review June 11, 2026 13:50
@Frodotus Frodotus force-pushed the feat/identity-ttl branch from 693a8bb to 4c95fde Compare June 11, 2026 13:50
@Frodotus Frodotus marked this pull request as draft June 11, 2026 13:58
@Frodotus Frodotus force-pushed the feat/identity-ttl branch from a786b8a to 161aad0 Compare June 11, 2026 14:03
@Frodotus Frodotus marked this pull request as ready for review June 11, 2026 14:04
@Frodotus Frodotus closed this Jun 16, 2026
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.

Refresh stale user/bot names and avatars (configurable identity cache TTL)

1 participant