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/post_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/post_store.go')
-rw-r--r-- | store/sqlstore/post_store.go | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/store/sqlstore/post_store.go b/store/sqlstore/post_store.go index 25c3c4913..92ee28ffa 100644 --- a/store/sqlstore/post_store.go +++ b/store/sqlstore/post_store.go @@ -35,9 +35,14 @@ const ( var lastPostTimeCache = utils.NewLru(LAST_POST_TIME_CACHE_SIZE) var lastPostsCache = utils.NewLru(LAST_POSTS_CACHE_SIZE) -func ClearPostCaches() { +func (s SqlPostStore) ClearCaches() { lastPostTimeCache.Purge() lastPostsCache.Purge() + + if s.metrics != nil { + s.metrics.IncrementMemCacheInvalidationCounter("Last Post Time - Purge") + s.metrics.IncrementMemCacheInvalidationCounter("Last Posts Cache - Purge") + } } func NewSqlPostStore(sqlStore SqlStore, metrics einterfaces.MetricsInterface) store.PostStore { @@ -326,6 +331,11 @@ func (s SqlPostStore) InvalidateLastPostTimeCache(channelId string) { // Keys are "{channelid}{limit}" and caching only occurs on limits of 30 and 60 lastPostsCache.Remove(channelId + "30") lastPostsCache.Remove(channelId + "60") + + if s.metrics != nil { + s.metrics.IncrementMemCacheInvalidationCounter("Last Post Time - Remove by Channel Id") + s.metrics.IncrementMemCacheInvalidationCounter("Last Posts Cache - Remove by Channel Id") + } } func (s SqlPostStore) GetEtag(channelId string, allowFromCache bool) store.StoreChannel { |