MM-31326: Fix Striped LRU to have minimum of 1 bucket (#16531)
* MM-31326: Fix Striped LRU to have minimum of 1 bucket https://mattermost.atlassian.net/browse/MM-31236 ```release-note NONE ``` * Using a maxInt function
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
1fe003aa36
Коммит
44eb3e3f97
@@ -291,7 +291,7 @@ func NewServer(options ...Option) (*Server, error) {
|
||||
if s.sessionCache, err = s.CacheProvider.NewCache(&cache.CacheOptions{
|
||||
Size: model.SESSION_CACHE_SIZE,
|
||||
Striped: true,
|
||||
StripedBuckets: runtime.NumCPU() - 1,
|
||||
StripedBuckets: maxInt(runtime.NumCPU()-1, 1),
|
||||
}); err != nil {
|
||||
return nil, errors.Wrap(err, "Unable to create session cache")
|
||||
}
|
||||
@@ -303,7 +303,7 @@ func NewServer(options ...Option) (*Server, error) {
|
||||
if s.statusCache, err = s.CacheProvider.NewCache(&cache.CacheOptions{
|
||||
Size: model.STATUS_CACHE_SIZE,
|
||||
Striped: true,
|
||||
StripedBuckets: runtime.NumCPU() - 1,
|
||||
StripedBuckets: maxInt(runtime.NumCPU()-1, 1),
|
||||
}); err != nil {
|
||||
return nil, errors.Wrap(err, "Unable to create status cache")
|
||||
}
|
||||
@@ -564,6 +564,13 @@ func NewServer(options ...Option) (*Server, error) {
|
||||
return s, nil
|
||||
}
|
||||
|
||||
func maxInt(a, b int) int {
|
||||
if a > b {
|
||||
return a
|
||||
}
|
||||
return b
|
||||
}
|
||||
|
||||
func (s *Server) RunJobs() {
|
||||
if s.runjobs {
|
||||
s.Go(func() {
|
||||
|
||||
@@ -133,7 +133,7 @@ func NewLocalCacheLayer(baseStore store.Store, metrics einterfaces.MetricsInterf
|
||||
DefaultExpiry: ROLE_CACHE_SEC * time.Second,
|
||||
InvalidateClusterEvent: model.CLUSTER_EVENT_INVALIDATE_CACHE_FOR_ROLES,
|
||||
Striped: true,
|
||||
StripedBuckets: runtime.NumCPU() - 1,
|
||||
StripedBuckets: maxInt(runtime.NumCPU()-1, 1),
|
||||
}); err != nil {
|
||||
return
|
||||
}
|
||||
@@ -271,7 +271,7 @@ func NewLocalCacheLayer(baseStore store.Store, metrics einterfaces.MetricsInterf
|
||||
DefaultExpiry: USER_PROFILE_BY_ID_SEC * time.Second,
|
||||
InvalidateClusterEvent: model.CLUSTER_EVENT_INVALIDATE_CACHE_FOR_PROFILE_BY_IDS,
|
||||
Striped: true,
|
||||
StripedBuckets: runtime.NumCPU() - 1,
|
||||
StripedBuckets: maxInt(runtime.NumCPU()-1, 1),
|
||||
}); err != nil {
|
||||
return
|
||||
}
|
||||
@@ -319,6 +319,13 @@ func NewLocalCacheLayer(baseStore store.Store, metrics einterfaces.MetricsInterf
|
||||
return
|
||||
}
|
||||
|
||||
func maxInt(a, b int) int {
|
||||
if a > b {
|
||||
return a
|
||||
}
|
||||
return b
|
||||
}
|
||||
|
||||
func (s LocalCacheStore) Reaction() store.ReactionStore {
|
||||
return s.reaction
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user