From 4a1802c039a0db2d97e8351c462963a99da857bf Mon Sep 17 00:00:00 2001 From: Joram Wilander Date: Mon, 5 Mar 2018 10:35:26 -0500 Subject: MM-9664 Add invalidation metrics for store caches (#8340) * Add invalidation metrics for store caches * Increment session invalidation metric * Fix tests --- store/sqlstore/post_store.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'store/sqlstore/post_store.go') 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 { -- cgit v1.2.3-1-g7c22