Commit de6f2bfa authored by Matija Obreza's avatar Matija Obreza

Clear caches

parent 2753976a
......@@ -47,6 +47,7 @@ import org.springframework.cache.Cache;
import org.springframework.cache.CacheManager;
import org.springframework.core.task.TaskExecutor;
import org.springframework.jdbc.core.RowCallbackHandler;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
......@@ -62,6 +63,7 @@ import com.hazelcast.monitor.LocalMapStats;
@Controller
@RequestMapping("/admin")
@PreAuthorize("hasRole('ADMINISTRATOR')")
public class AdminController {
public static final Log LOG = LogFactory.getLog(AdminController.class);
......@@ -369,6 +371,17 @@ public class AdminController {
return "redirect:/admin/";
}
@RequestMapping(method = RequestMethod.POST, value = "/clearCaches")
public String clearCaches() {
for (String cacheName : cacheManager.getCacheNames()) {
final Cache cache = cacheManager.getCache(cacheName);
LOG.info("Clearing cache " + cacheName);
cache.clear();
}
return "redirect:/admin/cache";
}
@RequestMapping("/cache")
public String cacheStats(Model model) {
List<CacheStats> cacheMaps = new ArrayList<CacheStats>();
......
......@@ -11,6 +11,12 @@
<h1>
<spring:message code="admin.cache.page.title" />
</h1>
<form method="post" action="<c:url value="/admin/clearCaches" />">
<input type="submit" class="btn btn-default" value="Clear all caches" />
<!-- CSRF protection -->
<input type="hidden" name="${_csrf.parameterName}" value="${_csrf.token}"/>
</form>
<c:forEach items="${cacheMaps}" var="cacheMap">
<h3><c:out value="${cacheMap.serviceName}" /> <c:out value="${cacheMap.name}" /></h3>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment