Conversation
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.
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. |
5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #209.
Summary
Revocation checked the store on every
session:openof an existing cookie session. This adds a worker-local LRU cache keyed by hashed session ID.revocation_cache_ttlseconds for real values andrevocation_error_cache_ttlfor cached errors (default5;0disables).session:destroyupdates the cache after writing the revocation marker."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 unitttl = 0)"open"/"closed"fail-mode results are cached