diff options
Diffstat (limited to 'store/sql_channel_store.go')
-rw-r--r-- | store/sql_channel_store.go | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/store/sql_channel_store.go b/store/sql_channel_store.go index aed568b46..001eaaa26 100644 --- a/store/sql_channel_store.go +++ b/store/sql_channel_store.go @@ -10,6 +10,7 @@ import ( l4g "github.com/alecthomas/log4go" "github.com/go-gorp/gorp" + "github.com/mattermost/platform/einterfaces" "github.com/mattermost/platform/model" "github.com/mattermost/platform/utils" ) @@ -684,13 +685,21 @@ func (us SqlChannelStore) InvalidateAllChannelMembersForUser(userId string) { } func (us SqlChannelStore) IsUserInChannelUseCache(userId string, channelId string) bool { + metrics := einterfaces.GetMetricsInterface() if cacheItem, ok := allChannelMembersForUserCache.Get(userId); ok { + if metrics != nil { + metrics.IncrementMemCacheHitCounter("All Channel Members for User") + } ids := cacheItem.(map[string]string) if _, ok := ids[channelId]; ok { return true } else { return false } + } else { + if metrics != nil { + metrics.IncrementMemCacheMissCounter("All Channel Members for User") + } } if result := <-us.GetAllChannelMembersForUser(userId, true); result.Err != nil { @@ -746,13 +755,25 @@ func (s SqlChannelStore) GetAllChannelMembersForUser(userId string, allowFromCac go func() { result := StoreResult{} + metrics := einterfaces.GetMetricsInterface() if allowFromCache { if cacheItem, ok := allChannelMembersForUserCache.Get(userId); ok { + if metrics != nil { + metrics.IncrementMemCacheHitCounter("All Channel Members for User") + } result.Data = cacheItem.(map[string]string) storeChannel <- result close(storeChannel) return + } else { + if metrics != nil { + metrics.IncrementMemCacheMissCounter("All Channel Members for User") + } + } + } else { + if metrics != nil { + metrics.IncrementMemCacheMissCounter("All Channel Members for User") } } @@ -788,16 +809,28 @@ func (us SqlChannelStore) InvalidateMemberCount(channelId string) { func (s SqlChannelStore) GetMemberCount(channelId string, allowFromCache bool) StoreChannel { storeChannel := make(StoreChannel, 1) + metrics := einterfaces.GetMetricsInterface() go func() { result := StoreResult{} if allowFromCache { if cacheItem, ok := channelMemberCountsCache.Get(channelId); ok { + if metrics != nil { + metrics.IncrementMemCacheHitCounter("Channel Member Counts") + } result.Data = cacheItem.(int64) storeChannel <- result close(storeChannel) return + } else { + if metrics != nil { + metrics.IncrementMemCacheMissCounter("Channel Member Counts") + } + } + } else { + if metrics != nil { + metrics.IncrementMemCacheMissCounter("Channel Member Counts") } } |