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
Этот коммит содержится в:
коммит произвёл
Harrison Healey
родитель
b46ced78de
Коммит
41b31b4c92
@@ -1176,6 +1176,8 @@ func updateNotifyProps(c *Context, w http.ResponseWriter, r *http.Request) {
|
|||||||
c.Err = result.Err
|
c.Err = result.Err
|
||||||
return
|
return
|
||||||
} else {
|
} else {
|
||||||
|
InvalidateCacheForUser(userId)
|
||||||
|
|
||||||
// return the updated notify properties including any unchanged ones
|
// return the updated notify properties including any unchanged ones
|
||||||
w.Write([]byte(model.MapToJson(member.NotifyProps)))
|
w.Write([]byte(model.MapToJson(member.NotifyProps)))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1398,6 +1398,8 @@ func updateUser(c *Context, w http.ResponseWriter, r *http.Request) {
|
|||||||
go sendEmailChangeUsername(c, rusers[1].Username, rusers[0].Username, rusers[0].Email, c.GetSiteURL())
|
go sendEmailChangeUsername(c, rusers[1].Username, rusers[0].Username, rusers[0].Email, c.GetSiteURL())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
InvalidateCacheForUser(user.Id)
|
||||||
|
|
||||||
updatedUser := rusers[0]
|
updatedUser := rusers[0]
|
||||||
updatedUser = sanitizeProfile(c, updatedUser)
|
updatedUser = sanitizeProfile(c, updatedUser)
|
||||||
|
|
||||||
@@ -1955,6 +1957,7 @@ func updateUserNotify(c *Context, w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
} else {
|
} else {
|
||||||
c.LogAuditWithUserId(user.Id, "")
|
c.LogAuditWithUserId(user.Id, "")
|
||||||
|
InvalidateCacheForUser(user.Id)
|
||||||
|
|
||||||
ruser := result.Data.([2]*model.User)[0]
|
ruser := result.Data.([2]*model.User)[0]
|
||||||
options := utils.Cfg.GetSanitizeOptions()
|
options := utils.Cfg.GetSanitizeOptions()
|
||||||
|
|||||||
@@ -112,6 +112,7 @@ func InvalidateCacheForUser(userId string) {
|
|||||||
|
|
||||||
func InvalidateCacheForUserSkipClusterSend(userId string) {
|
func InvalidateCacheForUserSkipClusterSend(userId string) {
|
||||||
Srv.Store.Channel().InvalidateAllChannelMembersForUser(userId)
|
Srv.Store.Channel().InvalidateAllChannelMembersForUser(userId)
|
||||||
|
Srv.Store.User().InvalidateProfilesInChannelCacheByUser(userId)
|
||||||
|
|
||||||
GetHubForUserId(userId).InvalidateUser(userId)
|
GetHubForUserId(userId).InvalidateUser(userId)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -555,6 +555,19 @@ func (us SqlUserStore) GetProfiles(teamId string, offset int, limit int) StoreCh
|
|||||||
return storeChannel
|
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) {
|
func (us SqlUserStore) InvalidateProfilesInChannelCache(channelId string) {
|
||||||
profilesInChannelCache.Remove(channelId)
|
profilesInChannelCache.Remove(channelId)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -143,6 +143,7 @@ type UserStore interface {
|
|||||||
UpdateMfaActive(userId string, active bool) StoreChannel
|
UpdateMfaActive(userId string, active bool) StoreChannel
|
||||||
Get(id string) StoreChannel
|
Get(id string) StoreChannel
|
||||||
GetAll() StoreChannel
|
GetAll() StoreChannel
|
||||||
|
InvalidateProfilesInChannelCacheByUser(userId string)
|
||||||
InvalidateProfilesInChannelCache(channelId string)
|
InvalidateProfilesInChannelCache(channelId string)
|
||||||
GetProfilesInChannel(channelId string, offset int, limit int, allowFromCache bool) StoreChannel
|
GetProfilesInChannel(channelId string, offset int, limit int, allowFromCache bool) StoreChannel
|
||||||
GetProfilesNotInChannel(teamId string, channelId string, offset int, limit int) StoreChannel
|
GetProfilesNotInChannel(teamId string, channelId string, offset int, limit int) StoreChannel
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user