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

api key cache ttl #160

Merged
merged 2 commits into from Apr 17, 2024
Merged

Conversation

breadchris
Copy link
Contributor

resolves #159

pkg/api/api.go Outdated
@@ -52,6 +56,15 @@ func NewScratchDataAPI(
return nil, err
}

apiKeyTTL := conf.API.APIKeyCacheTTL
if apiKeyTTL == 0 {
Copy link
Contributor

Choose a reason for hiding this comment

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

Does a TTL of 0 mean "we do not cache anything"? If so, then i'm okay removing this if-statement so that there's some way to disable the cache.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For this library, the answer seems to be yes and no? While the item will instantly expire, any lookup that is less than an hour https://github.com/jellydator/ttlcache/blob/v3/cache.go#L537 will succeed, but return an item that is expired, which you could check with item.ExpiresAt() < time.Now().

@breadchris breadchris marked this pull request as ready for review April 15, 2024 19:05
@poundifdef poundifdef merged commit 4e3459a into scratchdata:main Apr 17, 2024
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.

Cache API keys
2 participants