Adding memcache to getchannel (#4928)
Этот коммит содержится в:
коммит произвёл
enahum
родитель
547524e5ad
Коммит
42e04d92c4
@@ -79,7 +79,7 @@ func HasPermissionToChannelContext(c *Context, channelId string, permission *mod
|
||||
}
|
||||
}
|
||||
|
||||
cc := Srv.Store.Channel().Get(channelId)
|
||||
cc := Srv.Store.Channel().Get(channelId, true)
|
||||
if ccresult := <-cc; ccresult.Err == nil {
|
||||
channel := ccresult.Data.(*model.Channel)
|
||||
|
||||
|
||||
@@ -216,7 +216,7 @@ func updateChannel(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
sc := Srv.Store.Channel().Get(channel.Id)
|
||||
sc := Srv.Store.Channel().Get(channel.Id, true)
|
||||
cmc := Srv.Store.Channel().GetMember(channel.Id, c.Session.UserId)
|
||||
|
||||
if cresult := <-sc; cresult.Err != nil {
|
||||
@@ -264,6 +264,7 @@ func updateChannel(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
oldChannel.Type = channel.Type
|
||||
}
|
||||
|
||||
InvalidateCacheForChannel(oldChannel.Id)
|
||||
if ucresult := <-Srv.Store.Channel().Update(oldChannel); ucresult.Err != nil {
|
||||
c.Err = ucresult.Err
|
||||
return
|
||||
@@ -292,7 +293,7 @@ func updateChannelHeader(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
sc := Srv.Store.Channel().Get(channelId)
|
||||
sc := Srv.Store.Channel().Get(channelId, true)
|
||||
cmc := Srv.Store.Channel().GetMember(channelId, c.Session.UserId)
|
||||
|
||||
if cresult := <-sc; cresult.Err != nil {
|
||||
@@ -312,6 +313,7 @@ func updateChannelHeader(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
oldChannelHeader := channel.Header
|
||||
channel.Header = channelHeader
|
||||
|
||||
InvalidateCacheForChannel(channel.Id)
|
||||
if ucresult := <-Srv.Store.Channel().Update(channel); ucresult.Err != nil {
|
||||
c.Err = ucresult.Err
|
||||
return
|
||||
@@ -400,7 +402,7 @@ func updateChannelPurpose(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
sc := Srv.Store.Channel().Get(channelId)
|
||||
sc := Srv.Store.Channel().Get(channelId, true)
|
||||
cmc := Srv.Store.Channel().GetMember(channelId, c.Session.UserId)
|
||||
|
||||
if cresult := <-sc; cresult.Err != nil {
|
||||
@@ -419,6 +421,7 @@ func updateChannelPurpose(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
channel.Purpose = channelPurpose
|
||||
|
||||
InvalidateCacheForChannel(channel.Id)
|
||||
if ucresult := <-Srv.Store.Channel().Update(channel); ucresult.Err != nil {
|
||||
c.Err = ucresult.Err
|
||||
return
|
||||
@@ -542,7 +545,7 @@ func JoinChannelByName(c *Context, userId string, teamId string, channelName str
|
||||
}
|
||||
|
||||
func JoinChannelById(c *Context, userId string, channelId string) (*model.AppError, *model.Channel) {
|
||||
channelChannel := Srv.Store.Channel().Get(channelId)
|
||||
channelChannel := Srv.Store.Channel().Get(channelId, true)
|
||||
userChannel := Srv.Store.User().Get(userId)
|
||||
|
||||
return joinChannel(c, channelChannel, userChannel)
|
||||
@@ -713,7 +716,7 @@ func leave(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
params := mux.Vars(r)
|
||||
id := params["channel_id"]
|
||||
|
||||
sc := Srv.Store.Channel().Get(id)
|
||||
sc := Srv.Store.Channel().Get(id, true)
|
||||
uc := Srv.Store.User().Get(c.Session.UserId)
|
||||
ccm := Srv.Store.Channel().GetMemberCount(id, false)
|
||||
|
||||
@@ -769,7 +772,7 @@ func deleteChannel(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
params := mux.Vars(r)
|
||||
id := params["channel_id"]
|
||||
|
||||
sc := Srv.Store.Channel().Get(id)
|
||||
sc := Srv.Store.Channel().Get(id, true)
|
||||
scm := Srv.Store.Channel().GetMember(id, c.Session.UserId)
|
||||
cmc := Srv.Store.Channel().GetMemberCount(id, false)
|
||||
uc := Srv.Store.User().Get(c.Session.UserId)
|
||||
@@ -842,6 +845,7 @@ func deleteChannel(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
}()
|
||||
}
|
||||
|
||||
InvalidateCacheForChannel(channel.Id)
|
||||
if dresult := <-Srv.Store.Channel().Delete(channel.Id, model.GetMillis()); dresult.Err != nil {
|
||||
c.Err = dresult.Err
|
||||
return
|
||||
@@ -876,7 +880,7 @@ func getChannel(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
params := mux.Vars(r)
|
||||
id := params["channel_id"]
|
||||
|
||||
cchan := Srv.Store.Channel().Get(id)
|
||||
cchan := Srv.Store.Channel().Get(id, true)
|
||||
cmchan := Srv.Store.Channel().GetMember(id, c.Session.UserId)
|
||||
|
||||
if cresult := <-cchan; cresult.Err != nil {
|
||||
@@ -956,7 +960,7 @@ func getChannelStats(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
params := mux.Vars(r)
|
||||
id := params["channel_id"]
|
||||
|
||||
sc := Srv.Store.Channel().Get(id)
|
||||
sc := Srv.Store.Channel().Get(id, true)
|
||||
var channel *model.Channel
|
||||
if result := <-sc; result.Err != nil {
|
||||
c.Err = result.Err
|
||||
@@ -1026,7 +1030,7 @@ func addMember(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
sc := Srv.Store.Channel().Get(id)
|
||||
sc := Srv.Store.Channel().Get(id, true)
|
||||
ouc := Srv.Store.User().Get(c.Session.UserId)
|
||||
nuc := Srv.Store.User().Get(userId)
|
||||
if nresult := <-nuc; nresult.Err != nil {
|
||||
@@ -1081,7 +1085,7 @@ func removeMember(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
sc := Srv.Store.Channel().Get(channelId)
|
||||
sc := Srv.Store.Channel().Get(channelId, true)
|
||||
cmc := Srv.Store.Channel().GetMember(channelId, c.Session.UserId)
|
||||
ouc := Srv.Store.User().Get(userIdToRemove)
|
||||
|
||||
|
||||
@@ -119,7 +119,7 @@ func executeCommand(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
chanChan := Srv.Store.Channel().Get(commandArgs.ChannelId)
|
||||
chanChan := Srv.Store.Channel().Get(commandArgs.ChannelId, true)
|
||||
teamChan := Srv.Store.Team().Get(c.TeamId)
|
||||
userChan := Srv.Store.User().Get(c.Session.UserId)
|
||||
|
||||
|
||||
@@ -214,7 +214,7 @@ func sendBatchedEmailNotification(userId string, notifications []*batchedNotific
|
||||
|
||||
func renderBatchedPost(template *utils.HTMLTemplate, post *model.Post, teamName string, displayNameFormat string, translateFunc i18n.TranslateFunc) string {
|
||||
schan := Srv.Store.User().Get(post.UserId)
|
||||
cchan := Srv.Store.Channel().Get(post.ChannelId)
|
||||
cchan := Srv.Store.Channel().Get(post.ChannelId, true)
|
||||
|
||||
template.Props["Button"] = translateFunc("api.email_batching.render_batched_post.go_to_post")
|
||||
template.Props["PostMessage"] = getMessageForNotification(post, translateFunc)
|
||||
|
||||
@@ -584,7 +584,7 @@ func migrateFilenamesToFileInfos(post *model.Post) []*model.FileInfo {
|
||||
return []*model.FileInfo{}
|
||||
}
|
||||
|
||||
cchan := Srv.Store.Channel().Get(post.ChannelId)
|
||||
cchan := Srv.Store.Channel().Get(post.ChannelId, true)
|
||||
|
||||
// There's a weird bug that rarely happens where a post ends up with duplicate Filenames so remove those
|
||||
filenames := utils.RemoveDuplicatesFromStringArray(post.Filenames)
|
||||
|
||||
@@ -61,7 +61,7 @@ func createPost(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
post.UserId = c.Session.UserId
|
||||
|
||||
cchan := Srv.Store.Channel().Get(post.ChannelId)
|
||||
cchan := Srv.Store.Channel().Get(post.ChannelId, true)
|
||||
|
||||
if !HasPermissionToChannelContext(c, post.ChannelId, model.PERMISSION_CREATE_POST) {
|
||||
return
|
||||
@@ -166,6 +166,7 @@ func CreatePost(c *Context, post *model.Post, triggerWebhooks bool) (*model.Post
|
||||
}
|
||||
}
|
||||
|
||||
InvalidateCacheForChannel(rpost.ChannelId)
|
||||
InvalidateCacheForChannelPosts(rpost.ChannelId)
|
||||
|
||||
handlePostEvents(c, rpost, triggerWebhooks)
|
||||
@@ -245,7 +246,7 @@ func CreateWebhookPost(c *Context, channelId, text, overrideUsername, overrideIc
|
||||
|
||||
func handlePostEvents(c *Context, post *model.Post, triggerWebhooks bool) {
|
||||
tchan := Srv.Store.Team().Get(c.TeamId)
|
||||
cchan := Srv.Store.Channel().Get(post.ChannelId)
|
||||
cchan := Srv.Store.Channel().Get(post.ChannelId, true)
|
||||
uchan := Srv.Store.User().Get(post.UserId)
|
||||
|
||||
var team *model.Team
|
||||
|
||||
@@ -113,6 +113,7 @@ func InvalidateCacheForChannel(channelId string) {
|
||||
func InvalidateCacheForChannelSkipClusterSend(channelId string) {
|
||||
Srv.Store.User().InvalidateProfilesInChannelCache(channelId)
|
||||
Srv.Store.Channel().InvalidateMemberCount(channelId)
|
||||
Srv.Store.Channel().InvalidateChannel(channelId)
|
||||
}
|
||||
|
||||
func InvalidateCacheForChannelPosts(channelId string) {
|
||||
|
||||
@@ -55,7 +55,7 @@ func createIncomingHook(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
cchan := Srv.Store.Channel().Get(hook.ChannelId)
|
||||
cchan := Srv.Store.Channel().Get(hook.ChannelId, true)
|
||||
|
||||
hook.UserId = c.Session.UserId
|
||||
hook.TeamId = c.TeamId
|
||||
@@ -174,7 +174,7 @@ func createOutgoingHook(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
hook.TeamId = c.TeamId
|
||||
|
||||
if len(hook.ChannelId) != 0 {
|
||||
cchan := Srv.Store.Channel().Get(hook.ChannelId)
|
||||
cchan := Srv.Store.Channel().Get(hook.ChannelId, true)
|
||||
|
||||
var channel *model.Channel
|
||||
if result := <-cchan; result.Err != nil {
|
||||
@@ -447,7 +447,7 @@ func incomingWebhook(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
cchan = Srv.Store.Channel().GetByName(hook.TeamId, channelName)
|
||||
} else {
|
||||
cchan = Srv.Store.Channel().Get(hook.ChannelId)
|
||||
cchan = Srv.Store.Channel().Get(hook.ChannelId, true)
|
||||
}
|
||||
|
||||
overrideUsername := parsedRequest.Username
|
||||
|
||||
Ссылка в новой задаче
Block a user