-
Notifications
You must be signed in to change notification settings - Fork 804
Server Side Cache Invalidate Lookup Script
Victor Tomaili edited this page May 3, 2021
·
1 revision
First this code was produced by John Ranger, I am posting here as it had been requested in the thread I was reading, but I am thinking John has been busy.
Code for the Cache invalidate on Server side Serenity 1.9.9-based app. Create an MVC Controller with the following code inside:
using Serenity;
using System.Web.Mvc;
namespace ClientAndAssetManagement.Modules.Common.Control
{
[RoutePrefix("Control"), Route("{action=index}")]
public class ControlController : Controller
{
// GET: Control/InvalidateCache
public ActionResult InvalidateCache()
{
var ReturnResult = "ok";
try {
LocalCache.RemoveAll();
}
catch
{
ReturnResult = "not ok";
}
return Json (new { result = ReturnResult }, JsonRequestBehavior.AllowGet);
}
}
}
Call the code from where you Need to invalidate the Cache like this:
http://your.serenity.app/Control/InvalidateCache
As a result you will get a json Feedback with either
{ "result": "ok"}
or
{ "result": "not ok"}
Bonus: From within Powershell, call it like this:
$result= Invoke-RestMethod -uri "http://your.serenity.app/control/invalidatecache"
Copyright © Serenity Platform 2017-present. All rights reserved.
Documentation | Serene Template | Live Demo | Premium Support | Issues | Discussions