MM-59932: Migrate remaining caches to Redis (#27880)
- We introduce 2 new APIs: 1. Scan: this allows incremental iteration without blocking the Redis server and is the recommended way to iterate over keys. With this, we have entirely removed the need for Keys. 2. RemoveMulti: this allows deletion of multiple keys in a single operation which optimizes network round trips. - While here, we make a small improvement to GetStatusFromCache, where we remove the shallow copy which wasn't necessary because we always serialize the data from the cache. - We do not use Redis for session cache because of frequent requests to iterate the entire cache which leads to a lot of `SCAN` calls. - Avoid broadcasting status update messages for Redis case. - Setting cache expiry for status cache - Removing .Set method altogether to prevent any chances of setting an item with no expiry. https://mattermost.atlassian.net/browse/MM-59932 ```release-note NONE ```
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
e5842e67a8
Коммит
a1012d33eb
18
server/platform/services/cache/cache.go
поставляемый
18
server/platform/services/cache/cache.go
поставляемый
@@ -18,10 +18,6 @@ type Cache interface {
|
||||
// Purge is used to completely clear the cache.
|
||||
Purge() error
|
||||
|
||||
// Set adds the given key and value to the store without an expiry. If the key already exists,
|
||||
// it will overwrite the previous value.
|
||||
Set(key string, value any) error
|
||||
|
||||
// SetWithDefaultExpiry adds the given key and value to the store with the default expiry. If
|
||||
// the key already exists, it will overwrite the previous value
|
||||
SetWithDefaultExpiry(key string, value any) error
|
||||
@@ -31,16 +27,24 @@ type Cache interface {
|
||||
SetWithExpiry(key string, value any, ttl time.Duration) error
|
||||
|
||||
// Get the content stored in the cache for the given key, and decode it into the value interface.
|
||||
// Return ErrKeyNotFound if the key is missing from the cache
|
||||
// Returns ErrKeyNotFound if the key is missing from the cache
|
||||
Get(key string, value any) error
|
||||
|
||||
// GetMulti returns values for multiple keys in a single operation.
|
||||
// Returns ErrKeyNotFound if the key is missing from the cache.
|
||||
GetMulti(keys []string, values []any) []error
|
||||
|
||||
// Remove deletes the value for a given key.
|
||||
Remove(key string) error
|
||||
|
||||
// Keys returns a slice of the keys in the cache.
|
||||
Keys() ([]string, error)
|
||||
// RemoveMulti deletes multiple keys in a single operation.
|
||||
RemoveMulti(keys []string) error
|
||||
|
||||
// Scan allows incremental iteration over the entire key-space
|
||||
// in a performant manner. It provides a callback that consumers
|
||||
// can use to process the keys. If the callback returns an error,
|
||||
// the scan stops, returning the same error.
|
||||
Scan(f func([]string) error) error
|
||||
|
||||
// GetInvalidateClusterEvent returns the cluster event configured when this cache was created.
|
||||
GetInvalidateClusterEvent() model.ClusterEvent
|
||||
|
||||
Ссылка в новой задаче
Block a user