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/webhook_store.go | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'store/sqlstore/webhook_store.go') diff --git a/store/sqlstore/webhook_store.go b/store/sqlstore/webhook_store.go index 8a3720fa0..45ad90e52 100644 --- a/store/sqlstore/webhook_store.go +++ b/store/sqlstore/webhook_store.go @@ -26,8 +26,12 @@ const ( var webhookCache = utils.NewLru(WEBHOOK_CACHE_SIZE) -func ClearWebhookCaches() { +func (s SqlWebhookStore) ClearCaches() { webhookCache.Purge() + + if s.metrics != nil { + s.metrics.IncrementMemCacheInvalidationCounter("Webhook - Purge") + } } func NewSqlWebhookStore(sqlStore SqlStore, metrics einterfaces.MetricsInterface) store.WebhookStore { @@ -78,6 +82,9 @@ func (s SqlWebhookStore) CreateIndexesIfNotExists() { func (s SqlWebhookStore) InvalidateWebhookCache(webhookId string) { webhookCache.Remove(webhookId) + if s.metrics != nil { + s.metrics.IncrementMemCacheInvalidationCounter("Webhook - Remove by WebhookId") + } } func (s SqlWebhookStore) SaveIncoming(webhook *model.IncomingWebhook) store.StoreChannel { @@ -164,7 +171,7 @@ func (s SqlWebhookStore) PermanentDeleteIncomingByUser(userId string) store.Stor result.Err = model.NewAppError("SqlWebhookStore.DeleteIncomingByUser", "store.sql_webhooks.permanent_delete_incoming_by_user.app_error", nil, "id="+userId+", err="+err.Error(), http.StatusInternalServerError) } - ClearWebhookCaches() + s.ClearCaches() }) } @@ -175,7 +182,7 @@ func (s SqlWebhookStore) PermanentDeleteIncomingByChannel(channelId string) stor result.Err = model.NewAppError("SqlWebhookStore.DeleteIncomingByChannel", "store.sql_webhooks.permanent_delete_incoming_by_channel.app_error", nil, "id="+channelId+", err="+err.Error(), http.StatusInternalServerError) } - ClearWebhookCaches() + s.ClearCaches() }) } @@ -322,7 +329,7 @@ func (s SqlWebhookStore) PermanentDeleteOutgoingByChannel(channelId string) stor result.Err = model.NewAppError("SqlWebhookStore.DeleteOutgoingByChannel", "store.sql_webhooks.permanent_delete_outgoing_by_channel.app_error", nil, "id="+channelId+", err="+err.Error(), http.StatusInternalServerError) } - ClearWebhookCaches() + s.ClearCaches() }) } -- cgit v1.2.3-1-g7c22