diff options
author | Joram Wilander <jwawilander@gmail.com> | 2018-03-05 10:35:26 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-03-05 10:35:26 -0500 |
commit | 4a1802c039a0db2d97e8351c462963a99da857bf (patch) | |
tree | f083e9cd2c21434a6eba2dca7f90c127514bf727 /store/sqlstore/user_store.go | |
parent | fbff94f3be1bf596f2b94f593687d3b162413de9 (diff) | |
download | chat-4a1802c039a0db2d97e8351c462963a99da857bf.tar.gz chat-4a1802c039a0db2d97e8351c462963a99da857bf.tar.bz2 chat-4a1802c039a0db2d97e8351c462963a99da857bf.zip |
MM-9664 Add invalidation metrics for store caches (#8340)
* Add invalidation metrics for store caches
* Increment session invalidation metric
* Fix tests
Diffstat (limited to 'store/sqlstore/user_store.go')
-rw-r--r-- | store/sqlstore/user_store.go | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/store/sqlstore/user_store.go b/store/sqlstore/user_store.go index d67a45704..04e0c994c 100644 --- a/store/sqlstore/user_store.go +++ b/store/sqlstore/user_store.go @@ -38,13 +38,22 @@ type SqlUserStore struct { var profilesInChannelCache *utils.Cache = utils.NewLru(PROFILES_IN_CHANNEL_CACHE_SIZE) var profileByIdsCache *utils.Cache = utils.NewLru(PROFILE_BY_IDS_CACHE_SIZE) -func ClearUserCaches() { +func (us SqlUserStore) ClearCaches() { profilesInChannelCache.Purge() profileByIdsCache.Purge() + + if us.metrics != nil { + us.metrics.IncrementMemCacheInvalidationCounter("Profiles in Channel - Purge") + us.metrics.IncrementMemCacheInvalidationCounter("Profile By Ids - Purge") + } } func (us SqlUserStore) InvalidatProfileCacheForUser(userId string) { profileByIdsCache.Remove(userId) + + if us.metrics != nil { + us.metrics.IncrementMemCacheInvalidationCounter("Profile By Ids - Remove") + } } func NewSqlUserStore(sqlStore SqlStore, metrics einterfaces.MetricsInterface) store.UserStore { @@ -384,6 +393,9 @@ func (us SqlUserStore) InvalidateProfilesInChannelCacheByUser(userId string) { userMap := cacheItem.(map[string]*model.User) if _, userInCache := userMap[userId]; userInCache { profilesInChannelCache.Remove(key) + if us.metrics != nil { + us.metrics.IncrementMemCacheInvalidationCounter("Profiles in Channel - Remove by User") + } } } } @@ -391,6 +403,9 @@ func (us SqlUserStore) InvalidateProfilesInChannelCacheByUser(userId string) { func (us SqlUserStore) InvalidateProfilesInChannelCache(channelId string) { profilesInChannelCache.Remove(channelId) + if us.metrics != nil { + us.metrics.IncrementMemCacheInvalidationCounter("Profiles in Channel - Remove by Channel") + } } func (us SqlUserStore) GetProfilesInChannel(channelId string, offset int, limit int) store.StoreChannel { |