From e39ebd0883a20ab20977e054d09f605fb5139925 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Espino?= Date: Tue, 14 Aug 2018 19:30:27 +0200 Subject: MM-11678: Split the cache for includeDeleted and not includeDeleted memberships requests (#9254) * MM-11678: Split the cache for includeDeleted and not includeDeleted memberships requests * Updating properly the cache on sucess --- store/sqlstore/channel_store.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'store') diff --git a/store/sqlstore/channel_store.go b/store/sqlstore/channel_store.go index c073680f4..e158ba5ea 100644 --- a/store/sqlstore/channel_store.go +++ b/store/sqlstore/channel_store.go @@ -1093,6 +1093,7 @@ func (s SqlChannelStore) GetMember(channelId string, userId string) store.StoreC func (s SqlChannelStore) InvalidateAllChannelMembersForUser(userId string) { allChannelMembersForUserCache.Remove(userId) + allChannelMembersForUserCache.Remove(userId + "_deleted") if s.metrics != nil { s.metrics.IncrementMemCacheInvalidationCounter("All Channel Members for User - Remove by UserId") } @@ -1163,8 +1164,12 @@ func (s SqlChannelStore) GetMemberForPost(postId string, userId string) store.St func (s SqlChannelStore) GetAllChannelMembersForUser(userId string, allowFromCache bool, includeDeleted bool) store.StoreChannel { return store.Do(func(result *store.StoreResult) { + cache_key := userId + if includeDeleted { + cache_key += "_deleted" + } if allowFromCache { - if cacheItem, ok := allChannelMembersForUserCache.Get(userId); ok { + if cacheItem, ok := allChannelMembersForUserCache.Get(cache_key); ok { if s.metrics != nil { s.metrics.IncrementMemCacheHitCounter("All Channel Members for User") } @@ -1213,7 +1218,7 @@ func (s SqlChannelStore) GetAllChannelMembersForUser(userId string, allowFromCac result.Data = ids if allowFromCache { - allChannelMembersForUserCache.AddWithExpiresInSecs(userId, ids, ALL_CHANNEL_MEMBERS_FOR_USER_CACHE_SEC) + allChannelMembersForUserCache.AddWithExpiresInSecs(cache_key, ids, ALL_CHANNEL_MEMBERS_FOR_USER_CACHE_SEC) } }) } -- cgit v1.2.3-1-g7c22