summaryrefslogtreecommitdiffstats
path: root/api/admin.go
diff options
context:
space:
mode:
authorCorey Hulen <corey@hulen.com>2016-12-08 07:18:15 -0800
committerHarrison Healey <harrisonmhealey@gmail.com>2016-12-08 10:18:15 -0500
commitc4974374d9840caa6ec496c138a6220dd40afa54 (patch)
treec450cb63b76e032412f3e9c4433bae9518c89513 /api/admin.go
parent7acd135e021de28bac61e65d5293be8a4f0df328 (diff)
downloadchat-c4974374d9840caa6ec496c138a6220dd40afa54.tar.gz
chat-c4974374d9840caa6ec496c138a6220dd40afa54.tar.bz2
chat-c4974374d9840caa6ec496c138a6220dd40afa54.zip
PLT-4853 Adding cache purging to the server (server) (#4735)
* PLT-4853 Adding caching invalidation to HA * PLT-4853 Adding cach purging to the server
Diffstat (limited to 'api/admin.go')
-rw-r--r--api/admin.go19
1 files changed, 19 insertions, 0 deletions
diff --git a/api/admin.go b/api/admin.go
index d371d2515..20e5075b2 100644
--- a/api/admin.go
+++ b/api/admin.go
@@ -31,6 +31,7 @@ func InitAdmin() {
BaseRoutes.Admin.Handle("/config", ApiAdminSystemRequired(getConfig)).Methods("GET")
BaseRoutes.Admin.Handle("/save_config", ApiAdminSystemRequired(saveConfig)).Methods("POST")
BaseRoutes.Admin.Handle("/reload_config", ApiAdminSystemRequired(reloadConfig)).Methods("GET")
+ BaseRoutes.Admin.Handle("/invalidate_all_caches", ApiAdminSystemRequired(invalidateAllCaches)).Methods("GET")
BaseRoutes.Admin.Handle("/test_email", ApiAdminSystemRequired(testEmail)).Methods("POST")
BaseRoutes.Admin.Handle("/recycle_db_conn", ApiAdminSystemRequired(recycleDatabaseConnection)).Methods("GET")
BaseRoutes.Admin.Handle("/analytics/{id:[A-Za-z0-9]+}/{name:[A-Za-z0-9_]+}", ApiAdminSystemRequired(getAnalytics)).Methods("GET")
@@ -145,6 +146,24 @@ func reloadConfig(c *Context, w http.ResponseWriter, r *http.Request) {
ReturnStatusOK(w)
}
+func invalidateAllCaches(c *Context, w http.ResponseWriter, r *http.Request) {
+ debug.FreeOSMemory()
+
+ InvalidateAllCaches()
+
+ if einterfaces.GetClusterInterface() != nil {
+ err := einterfaces.GetClusterInterface().InvalidateAllCaches()
+ if err != nil {
+ c.Err = err
+ return
+ }
+
+ }
+
+ w.Header().Set("Cache-Control", "no-cache, no-store, must-revalidate")
+ ReturnStatusOK(w)
+}
+
func saveConfig(c *Context, w http.ResponseWriter, r *http.Request) {
cfg := model.ConfigFromJson(r.Body)
if cfg == nil {