From 41b31b4c92932a74bb8cc9fbe6b64d327d903a37 Mon Sep 17 00:00:00 2001 From: Corey Hulen Date: Thu, 10 Nov 2016 06:25:23 -0800 Subject: PLT-4716 fixes cache invalidation issue (#4518) * PLT-4716 fixes cache invalidation issue * Adding missing interface * Adding cache invalidation to channel notification preferences * Adding cache invalidation to channel notification preferences --- store/sql_user_store.go | 13 +++++++++++++ store/store.go | 1 + 2 files changed, 14 insertions(+) (limited to 'store') diff --git a/store/sql_user_store.go b/store/sql_user_store.go index 984b544d7..aa3bb4380 100644 --- a/store/sql_user_store.go +++ b/store/sql_user_store.go @@ -555,6 +555,19 @@ func (us SqlUserStore) GetProfiles(teamId string, offset int, limit int) StoreCh return storeChannel } +func (us SqlUserStore) InvalidateProfilesInChannelCacheByUser(userId string) { + keys := profilesInChannelCache.Keys() + + for _, key := range keys { + if cacheItem, ok := profilesInChannelCache.Get(key); ok { + userMap := cacheItem.(map[string]*model.User) + if _, userInCache := userMap[userId]; userInCache { + profilesInChannelCache.Remove(key) + } + } + } +} + func (us SqlUserStore) InvalidateProfilesInChannelCache(channelId string) { profilesInChannelCache.Remove(channelId) } diff --git a/store/store.go b/store/store.go index 83a077c10..d0790263a 100644 --- a/store/store.go +++ b/store/store.go @@ -143,6 +143,7 @@ type UserStore interface { UpdateMfaActive(userId string, active bool) StoreChannel Get(id string) StoreChannel GetAll() StoreChannel + InvalidateProfilesInChannelCacheByUser(userId string) InvalidateProfilesInChannelCache(channelId string) GetProfilesInChannel(channelId string, offset int, limit int, allowFromCache bool) StoreChannel GetProfilesNotInChannel(teamId string, channelId string, offset int, limit int) StoreChannel -- cgit v1.2.3-1-g7c22