Skip to content

Conversation

mastercactapus
Copy link
Member

Description:
This PR adds a cache for API key policy info and last-usage updates.

This ensures that last-used info isn't updated more than once per minute (per instance). The policy cache ensures that repeated use of the same key doesn't require fetching and parsing the policy JSON for each request.

Additionally, invalid keys (that otherwise have a valid signature) are put in a negative cache. This means when a key is deleted, only the first request will require a DB lookup and subsequent requests from the same key will be rejected immediately.

Which issue(s) this PR fixes:
Part of #3007

Copy link
Contributor

@allending313 allending313 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@mastercactapus mastercactapus merged commit b25e705 into master Sep 21, 2023
@mastercactapus mastercactapus deleted the gql-key-policy-cache branch September 21, 2023 19:18
allending313 pushed a commit that referenced this pull request Sep 27, 2023
* cache policy and rate-limit last used update

* comments

* fix comments

* remove error return (no possible err)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants