<%@ page import="com.atlassian.cache.Cache" %> <%@ page import="com.atlassian.cache.CacheManager" %> <%@ page import="com.atlassian.spring.container.ContainerManager" %> <%@ page import="java.util.ArrayList" %> <%@ page import="java.util.Collections" %> <%@ page import="java.util.Comparator" %> <%@ page import="java.util.List" %> <%@ page import="com.atlassian.confluence.util.GeneralUtil" %> <%@ page import="com.atlassian.confluence.util.HtmlUtil" %> <%@ page contentType="text/html;charset=UTF-8" language="java" %> <% CacheManager cacheManager = (CacheManager) ContainerManager.getComponent("cacheManager"); List caches = new ArrayList(cacheManager.getCaches()); // Collections.sort(caches, new Comparator() { // public int compare(Cache c1, Cache c2) { // return new Integer(c2.getKeys().size()).compareTo(c1.getKeys().size()); // } // }); String cacheName = request.getParameter("cache"); Cache cache = null; if (cacheName != null) cache = cacheManager.getCache(cacheName); %> Confluence cache contents

Confluence cache contents

<% if (cache != null) { %>

Cache: <%= HtmlUtil.htmlEncode(cache.getName()) %> (<%= cache.getKeys().size() %> items)

<% int count = 0; %> <% for (Object key : cache.getKeys()) { %> <% if (++count > 100) break; %> <% } %> <% if (count > 100) { %> <% } %>
KeyValue
<%= HtmlUtil.htmlEncode(key.toString()) %> (<%= key.getClass().getSimpleName() %>) <% final Object value = cache.get(key); %> <% if (value == null) {%> NULL <% } else { %> <%= HtmlUtil.htmlEncode(value.toString()) %> (<%= value.getClass().getSimpleName() %>) <% } %>
(truncated at 100)
<% } else { %>

No cache selected.

<% } %>

Cache selection

Select a cache from the list:

    <% for (Cache c : caches) { %> <% if (c.getKeys().isEmpty()) continue; %> <% String name = c.getName().replaceAll("^(.{10}).*\\.(.*)$", "$1...$2").replaceAll("\\.\\.\\.(.{27}).{3,}", "...$1..."); %> <% if (c.getName().equals(cacheName)) { %>
  • <%= HtmlUtil.htmlEncode(name) %> (<%= c.getKeys().size() %>)
  • <% } else { %>
  • " title="<%= HtmlUtil.htmlEncode(c.getName()) %>"><%= HtmlUtil.htmlEncode(name) %> (<%= c.getKeys().size() %>)
  • <% } %> <% } %>