diff --git a/app/server.go b/app/server.go index 9ddf68cc0d..92ab55d3cc 100644 --- a/app/server.go +++ b/app/server.go @@ -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() { diff --git a/store/localcachelayer/layer.go b/store/localcachelayer/layer.go index 34b796cdd8..179000e79c 100644 --- a/store/localcachelayer/layer.go +++ b/store/localcachelayer/layer.go @@ -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 }