diff --git a/store/sqlstore/channel_store.go b/store/sqlstore/channel_store.go index 4839fa0ca5..7d694eed29 100644 --- a/store/sqlstore/channel_store.go +++ b/store/sqlstore/channel_store.go @@ -1107,14 +1107,8 @@ func (s SqlChannelStore) GetByNames(teamId string, names []string, allowFromCach } visited[name] = struct{}{} if cacheItem, ok := channelByNameCache.Get(teamId + name); ok { - if s.metrics != nil { - s.metrics.IncrementMemCacheHitCounter("Channel By Name") - } channels = append(channels, cacheItem.(*model.Channel)) } else { - if s.metrics != nil { - s.metrics.IncrementMemCacheMissCounter("Channel By Name") - } misses = append(misses, name) } } @@ -1146,6 +1140,15 @@ func (s SqlChannelStore) GetByNames(teamId string, names []string, allowFromCach channelByNameCache.AddWithExpiresInSecs(teamId+channel.Name, channel, CHANNEL_CACHE_SEC) channels = append(channels, channel) } + // Not all channels are in cache. Increment aggregate miss counter. + if s.metrics != nil { + s.metrics.IncrementMemCacheMissCounter("Channel By Name - Aggregate") + } + } else { + // All of the channel names are in cache. Increment aggregate hit counter. + if s.metrics != nil { + s.metrics.IncrementMemCacheHitCounter("Channel By Name - Aggregate") + } } return channels, nil