Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cache valid API keys #99

Merged
merged 1 commit into from
Dec 12, 2023
Merged

Conversation

Carifio24
Copy link
Member

This PR adds a map of API keys that the server has found to be valid and stores them locally. This gives us the benefit of improved performance (no need for a database query) while still allowing the database to be persistent storage. If the server is reset/a new server is spun up, it can just build up the cache as it gets requests.

A few notes:

  • Our total number of unique API keys is small, so this shouldn't use much space in memory.
  • This doesn't do anything with invalid API keys. I guess there's no reason that we couldn't, but I don't really expect this to be a concern - we're more likely to get requests that don't have a key. Also, there's always the (very) slim chance that we add a new API key that clashes with something that has already been marked bad.
  • This does mean that updates to an already-used API key (e.g. permissions) would require a server restart. We basically never change these, but it's worth noting in case this ever happens.

@Carifio24 Carifio24 merged commit 308e29d into cosmicds:main Dec 12, 2023
1 check passed
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