Skip to content

Fix user config cache expiry under load - #50

Merged
dawid-nowak merged 1 commit into
mainfrom
user/luca/fix-user-config-cache-ttl
Jul 2, 2026
Merged

Fix user config cache expiry under load#50
dawid-nowak merged 1 commit into
mainfrom
user/luca/fix-user-config-cache-ttl

Conversation

@lucarlig

@lucarlig lucarlig commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Problem

lru_time_cache::LruCache refreshes an entry timestamp on access. The user-config cache used get_mut, so active subjects that received traffic more often than the configured expiry kept serving the original config indefinitely. Runtime-published Redis updates, including newly created virtual hosts, were not observed until traffic stopped long enough for the entry to expire or the process restarted.

Summary

  • track user-config cache freshness from insertion time instead of LruCache access time
  • refresh Redis config once nonzero cache expiry elapses even for hot subjects
  • add unit coverage for insertion-time expiry and access not renewing freshness

Validation

  • cargo fmt --check
  • cargo test -p contextforge-gateway-rs-lib
  • cargo clippy -p contextforge-gateway-rs-lib --all-targets -- -D warnings

Signed-off-by: lucarlig <luca.carlig@ibm.com>
@lucarlig
lucarlig requested a review from dawid-nowak July 2, 2026 13:35
@lucarlig
lucarlig marked this pull request as ready for review July 2, 2026 13:36
@dawid-nowak
dawid-nowak merged commit ce9c0b4 into main Jul 2, 2026
7 checks passed
@lucarlig lucarlig self-assigned this Jul 6, 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.

2 participants