summaryrefslogtreecommitdiffstats
path: root/store
diff options
context:
space:
mode:
authorJesús Espino <jespinog@gmail.com>2018-08-14 19:30:27 +0200
committerCarlos Tadeu Panato Junior <ctadeu@gmail.com>2018-08-14 19:30:27 +0200
commite39ebd0883a20ab20977e054d09f605fb5139925 (patch)
tree679e8ffbd8bf18169dec51641e1d3a24ef45bdb9 /store
parent687700a989810ec99bc6b52a1e3900a237a4cd54 (diff)
downloadchat-e39ebd0883a20ab20977e054d09f605fb5139925.tar.gz
chat-e39ebd0883a20ab20977e054d09f605fb5139925.tar.bz2
chat-e39ebd0883a20ab20977e054d09f605fb5139925.zip
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
Diffstat (limited to 'store')
-rw-r--r--store/sqlstore/channel_store.go9
1 files changed, 7 insertions, 2 deletions
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)
}
})
}