From 3e1fc76bf97703e730038d7bead7a35cbda970cd Mon Sep 17 00:00:00 2001 From: Corey Hulen Date: Tue, 25 Oct 2016 05:56:06 -0700 Subject: Fixing clustering problem (#4320) --- api/context.go | 11 ++++++++--- api/web_hub.go | 23 ++++++----------------- 2 files changed, 14 insertions(+), 20 deletions(-) (limited to 'api') diff --git a/api/context.go b/api/context.go index 257f43174..7466d0b05 100644 --- a/api/context.go +++ b/api/context.go @@ -474,6 +474,14 @@ func GetSession(token string) *model.Session { func RemoveAllSessionsForUserId(userId string) { + RemoveAllSessionsForUserIdSkipClusterSend(userId) + + if einterfaces.GetClusterInterface() != nil { + einterfaces.GetClusterInterface().RemoveAllSessionsForUserId(userId) + } +} + +func RemoveAllSessionsForUserIdSkipClusterSend(userId string) { keys := sessionCache.Keys() for _, key := range keys { @@ -485,9 +493,6 @@ func RemoveAllSessionsForUserId(userId string) { } } - if einterfaces.GetClusterInterface() != nil { - einterfaces.GetClusterInterface().RemoveAllSessionsForUserId(userId) - } } func AddSessionToCache(session *model.Session) { diff --git a/api/web_hub.go b/api/web_hub.go index 5f480880e..23c01eb1b 100644 --- a/api/web_hub.go +++ b/api/web_hub.go @@ -101,30 +101,19 @@ func PublishSkipClusterSend(message *model.WebSocketEvent) { } func InvalidateCacheForUser(userId string) { - - Srv.Store.Channel().InvalidateAllChannelMembersForUser(userId) - - for _, hub := range hubs { - hub.InvalidateUser(userId) - } + InvalidateCacheForUserSkipClusterSend(userId) if einterfaces.GetClusterInterface() != nil { einterfaces.GetClusterInterface().InvalidateCacheForUser(userId) } } -func InvalidateCacheForChannel(channelId string) { - - // XXX TODO FIX ME - // This can be removed, but the performance branch - // needs to be merged into master so it can be removed - // from the enterprise repo as well. - - // hub.invalidateChannel <- channelId +func InvalidateCacheForUserSkipClusterSend(userId string) { + Srv.Store.Channel().InvalidateAllChannelMembersForUser(userId) - // if einterfaces.GetClusterInterface() != nil { - // einterfaces.GetClusterInterface().InvalidateCacheForChannel(channelId) - // } + for _, hub := range hubs { + hub.InvalidateUser(userId) + } } func (h *Hub) Register(webConn *WebConn) { -- cgit v1.2.3-1-g7c22