From c4974374d9840caa6ec496c138a6220dd40afa54 Mon Sep 17 00:00:00 2001 From: Corey Hulen Date: Thu, 8 Dec 2016 07:18:15 -0800 Subject: 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 --- api/admin.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'api/admin.go') 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 { -- cgit v1.2.3-1-g7c22