Skip to content

perf(*): Cache revocation lookups in a worker-local LRU - #213

Open
Hockenba wants to merge 6 commits into
bungle:masterfrom
geico:feat/revocation-lookup-cache
Open

Hockenba wants to merge 6 commits into
bungle:masterfrom
geico:feat/revocation-lookup-cache

Conversation

@Hockenba

@Hockenba Hockenba commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

Follow-up to #209.

Summary

Revocation checked the store on every session:open of an existing cookie session. This adds a worker-local LRU cache keyed by hashed session ID.

  • Cache hit: return the cached result.
  • Cache miss: query the store and cache for revocation_cache_ttl seconds for real values and revocation_error_cache_ttl for cached errors (default 5; 0 disables).
  • session:destroy updates the cache after writing the revocation marker.
  • Store down: "open" caches not-revoked; "closed" caches the error. Later requests in the TTL do not retry the store.

Adds lua-resty-lrucache >= 0.09.

Test plan

  • make unit
  • Cache hit, post-destroy update, TTL expiry, disable (ttl = 0)
  • "open" / "closed" fail-mode results are cached

Revocation checked the store on every open of an existing cookie session,
so many requests reusing one session produced one lookup each. Cache the
result for the hashed session id in a worker-local lrucache and reuse it
for revocation_cache_ttl seconds (defaults to 5, 0 disables caching).
Marking a session revoked updates the cache right after the store write,
so a just-revoked session is rejected without waiting for the entry to
expire. The ttl is the maximum stale window for a revocation written by
another worker.
@Hockenba

Copy link
Copy Markdown
Contributor Author

@bungle Please review when you can. This change was requested by apache/apisix#13651 (review). The goal is to reduce the calls to Redis by adding a small in memory cache of the denylist.

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.

1 participant