summaryrefslogtreecommitdiffstats
path: root/api/post.go
diff options
context:
space:
mode:
authorChristopher Speller <crspeller@gmail.com>2016-12-13 22:24:24 -0500
committerenahum <nahumhbl@gmail.com>2016-12-14 00:24:24 -0300
commit86fb0d87a3a09b237bec124ce0e74cd05aa164be (patch)
treedab6753888596cc2ba8df8c273ced364bff6b26d /api/post.go
parent2e58f7504b79fc85d43468ffa06954a23221ea32 (diff)
downloadchat-86fb0d87a3a09b237bec124ce0e74cd05aa164be.tar.gz
chat-86fb0d87a3a09b237bec124ce0e74cd05aa164be.tar.bz2
chat-86fb0d87a3a09b237bec124ce0e74cd05aa164be.zip
Adding caching layer to some posts calls (#4779)
Diffstat (limited to 'api/post.go')
-rw-r--r--api/post.go10
1 files changed, 8 insertions, 2 deletions
diff --git a/api/post.go b/api/post.go
index 143dbf7e1..a4a493060 100644
--- a/api/post.go
+++ b/api/post.go
@@ -166,6 +166,8 @@ func CreatePost(c *Context, post *model.Post, triggerWebhooks bool) (*model.Post
}
}
+ InvalidateCacheForChannelPosts(rpost.ChannelId)
+
handlePostEvents(c, rpost, triggerWebhooks)
return rpost, nil
@@ -1226,6 +1228,8 @@ func updatePost(c *Context, w http.ResponseWriter, r *http.Request) {
go Publish(message)
+ InvalidateCacheForChannelPosts(rpost.ChannelId)
+
w.Write([]byte(rpost.ToJson()))
}
}
@@ -1278,7 +1282,7 @@ func getPosts(c *Context, w http.ResponseWriter, r *http.Request) {
return
}
- etagChan := Srv.Store.Post().GetEtag(id)
+ etagChan := Srv.Store.Post().GetEtag(id, true)
if !HasPermissionToChannelContext(c, id, model.PERMISSION_CREATE_POST) {
return
@@ -1508,6 +1512,8 @@ func deletePost(c *Context, w http.ResponseWriter, r *http.Request) {
go DeletePostFiles(post)
go DeleteFlaggedPost(c.Session.UserId, post)
+ InvalidateCacheForChannelPosts(post.ChannelId)
+
result := make(map[string]string)
result["id"] = postId
w.Write([]byte(model.MapToJson(result)))
@@ -1567,7 +1573,7 @@ func getPostsBeforeOrAfter(c *Context, w http.ResponseWriter, r *http.Request, b
}
// We can do better than this etag in this situation
- etagChan := Srv.Store.Post().GetEtag(id)
+ etagChan := Srv.Store.Post().GetEtag(id, true)
if !HasPermissionToChannelContext(c, id, model.PERMISSION_READ_CHANNEL) {
return