forked from vimeo/galaxycache
-
Notifications
You must be signed in to change notification settings - Fork 0
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
*: add TTL functionality #1
Merged
Conversation
This file contains 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
Add expiration time in preparation for the TTL feature.
TTLs are based on expiration in the LRU - during getting if the value is expired then it is removed from the LRU and we return nothing. This is needed to have short-lived values in a distributed system. To achieve this, expand the `valWithStat` struct with `expire time.Time`. Then, expand all of the related interfaces: - Codecs - `setLRUOnEvicted` - etc. Since the HTTP interface returns in the body raw bytes, send the expiration timestamp with headers. Expand the test in `http/http_test.go` to test whether the keys are being regenerated after the timestamp. Copy over a test from mailgun/groupcache for TTLs in the LRU.
GiedriusS
added a commit
to GiedriusS/thanos
that referenced
this pull request
Nov 22, 2021
Adds TTL support to galaxycache as per this pull request: thanos-community/galaxycache#1 Signed-off-by: Giedrius Statkevičius <[email protected]>
akanshat
approved these changes
Nov 24, 2021
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💪🏻
onprem
approved these changes
Nov 24, 2021
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
GiedriusS
added a commit
to GiedriusS/thanos
that referenced
this pull request
Dec 13, 2021
Adds TTL support to galaxycache as per this pull request: thanos-community/galaxycache#1 Signed-off-by: Giedrius Statkevičius <[email protected]>
GiedriusS
added a commit
to thanos-io/thanos
that referenced
this pull request
Jan 6, 2022
* cache: add groupcache Signed-off-by: Giedrius Statkevičius <[email protected]> * implement Cache interface on groupcache Signed-off-by: akanshat <[email protected]> * move BucketCacheKey to a new package Signed-off-by: akanshat <[email protected]> * add copyright to new pkg cachekey Signed-off-by: akanshat <[email protected]> * add a fix to return partial results if Get fails Signed-off-by: akanshat <[email protected]> * migrate from groupcache to galaxycache Signed-off-by: akanshat <[email protected]> * instrument metrics for galaxyCache Signed-off-by: akanshat <[email protected]> * add e2e test for store with groupcache Signed-off-by: akanshat <[email protected]> * fix collector interface on CacheStatsCollector Signed-off-by: akanshat <[email protected]> * cache: fix / clean up tests Signed-off-by: Giedrius Statkevičius <[email protected]> * groupcache: support IterVerb Signed-off-by: Giedrius Statkevičius <[email protected]> * groupcache: changes according to comments Signed-off-by: Giedrius Statkevičius <[email protected]> * store: fix groupcache test Signed-off-by: akanshat <[email protected]> * cache: add TTL support Adds TTL support to galaxycache as per this pull request: thanos-community/galaxycache#1 Signed-off-by: Giedrius Statkevičius <[email protected]> * move caching_bucket_config to pkg cache Signed-off-by: akanshat <[email protected]> * modify groupcacheCfg Signed-off-by: akanshat <[email protected]> * remove duplicate CachingBucketConfig Signed-off-by: akanshat <[email protected]> * remove duplicate calls to NewCachingBucketConfig Signed-off-by: akanshat <[email protected]> * refactor cache configuration Signed-off-by: akanshat <[email protected]> * implement suggestions from comments Signed-off-by: akanshat <[email protected]> * *: formatting changes Signed-off-by: Giedrius Statkevičius <[email protected]> * *: linter fixes Signed-off-by: Giedrius Statkevičius <[email protected]> Co-authored-by: Giedrius Statkevičius <[email protected]> Co-authored-by: Giedrius Statkevičius <[email protected]>
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.
Add the ability to specify TTLs for values in the codec interface. With this, the expiration timestamp is passed to the LRU. When getting values from the LRU, the timestamp is checked - if the value has expired then we discard that value and return nothing. Inspired by https://github.com/mailgun/groupcache.
Added tests to
http/http_test.go
to test whether the keys get regenerated properly. Improvedlru_test.go
with expiration tests.More details in the commits.