-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add memcached support to index cache (#1881)
* Moved index cache key struct outside of the file containing the in-memory cache backend because generic Signed-off-by: Marco Pracucci <[email protected]> * Added cacheKey.string() to make it memcached friendly Signed-off-by: Marco Pracucci <[email protected]> * Added MemcachedIndexCache support Signed-off-by: Marco Pracucci <[email protected]> * Export Prometheus metrics from MemcachedIndexCache Signed-off-by: Marco Pracucci <[email protected]> * Fixed linter issues Signed-off-by: Marco Pracucci <[email protected]> * Simplified workers wait group in memcachedClient Signed-off-by: Marco Pracucci <[email protected]> * Fixed memcached client GetMulti() results batches channel buffer Signed-off-by: Marco Pracucci <[email protected]> * Wait for addrs resolution gorouting to complete on memcachedClient.Stop() Signed-off-by: Marco Pracucci <[email protected]> * Return struct from NewMemcachedClient() Signed-off-by: Marco Pracucci <[email protected]> * Update pkg/cacheutil/memcached_client.go Co-Authored-By: Bartlomiej Plotka <[email protected]> Signed-off-by: Marco Pracucci <[email protected]> * Simplified memcachedClient tests Signed-off-by: Marco Pracucci <[email protected]> * Cleaned up code based on feedback Signed-off-by: Marco Pracucci <[email protected]> * Removed error from GetMulti() return and introduced metrics and tracing in MemcachedClient Signed-off-by: Marco Pracucci <[email protected]> * Fixed compilation errors in store E2E tests Signed-off-by: Marco Pracucci <[email protected]> * Added leaktest check to all tests Signed-off-by: Marco Pracucci <[email protected]> * Introduced --index.cache-config support Signed-off-by: Marco Pracucci <[email protected]> * Fixed compilation errors in store E2E tests Signed-off-by: Marco Pracucci <[email protected]> * Updated store flags doc Signed-off-by: Marco Pracucci <[email protected]> * Updated index cache doc Signed-off-by: Marco Pracucci <[email protected]> * Updated changelog Signed-off-by: Marco Pracucci <[email protected]> * Increased default memcached client timeout from 100ms to 500ms Signed-off-by: Marco Pracucci <[email protected]> * Disabled memcached client max batch size by default Signed-off-by: Marco Pracucci <[email protected]> * Fixed index cache key max length Signed-off-by: Marco Pracucci <[email protected]> * Removed TODO from memcached client since looks the general consensus is to have a global limit on the max concurrent batches Signed-off-by: Marco Pracucci <[email protected]> * Allow to configure in-memory index cache using byte units Signed-off-by: Marco Pracucci <[email protected]> * Refactored index cache config file doc Signed-off-by: Marco Pracucci <[email protected]> * Fixed nits in comments Signed-off-by: Marco Pracucci <[email protected]> * Replaced hardcoded 16 with ULID calculated length based on review comment Signed-off-by: Marco Pracucci <[email protected]> * Do not expose jumpHash func Signed-off-by: Marco Pracucci <[email protected]> * Updated changelog Signed-off-by: Marco Pracucci <[email protected]> * Switched MemcachedClient GetMulti() concurrency limit to a gate Signed-off-by: Marco Pracucci <[email protected]> * Fixed flaky tests Signed-off-by: Marco Pracucci <[email protected]> * Fixed typos in comments Signed-off-by: Marco Pracucci <[email protected]> * Renamed memcached config option addrs to addresses Signed-off-by: Marco Pracucci <[email protected]> Co-authored-by: Bartlomiej Plotka <[email protected]>
- Loading branch information
Showing
23 changed files
with
2,104 additions
and
133 deletions.
There are no files selected for viewing
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package cacheutil | ||
|
||
// jumpHash consistently chooses a hash bucket number in the range | ||
// [0, numBuckets) for the given key. numBuckets must be >= 1. | ||
// | ||
// Copied from github.com/dgryski/go-jump/blob/master/jump.go (MIT license). | ||
func jumpHash(key uint64, numBuckets int) int32 { | ||
var b int64 = -1 | ||
var j int64 | ||
|
||
for j < int64(numBuckets) { | ||
b = j | ||
key = key*2862933555777941757 + 1 | ||
j = int64(float64(b+1) * (float64(int64(1)<<31) / float64((key>>33)+1))) | ||
} | ||
|
||
return int32(b) | ||
} |
Oops, something went wrong.