Name
global.CacheInspectAjax
Description
Cache inspector backend
Script
var CacheInspectAjax = Class.create();
CacheInspectAjax.prototype = Object.extendsObject(AbstractAjaxProcessor, {
process: function() {
if (!gs.hasRole('maint'))
return;
if (this.getChars() == "list")
this._generateList();
else if (this.getChars() == "get")
this._getData();
},
_generateList: function() {
var i = null;
if (this.getType().equals("shr")) {
i = GlideCacheManager.getSharedKeys();
} else if (this.getType().equals("exp")) {
var ks = GlideCompiler.getAllCache().keySet();
var al = new Packages.java.util.TreeSet(ks);
i = al.iterator();
} else {
i = GlideCacheManager.getPrivateKeys(this.getName() ? this.getName() : null);
}
var filter = this.getParameter("sysparm_filter");
if (i != null) {
while(i.hasNext()) {
var key = i.next();
var match = false;
if (!filter)
match = true;
else if (filter.startsWith("$") && key.startsWith(filter.substring(1)))
match = true;
else if (key.indexOf(filter) > -1)
match = true;
if (match)
this._addBasicResponse(key, key, key);
}
}
},
_getData: function() {
if (this.getType().equals("shr")) {
v = GlideCacheManager.getSharedString(this.getName());
} else if (this.getType().equals("exp")) {
if (gs.hasRole("maint")) {
v = GlideCompiler.getCacheDetails(this.getName(),true);
}
else {
v = GlideCompiler.getCacheDetails(this.getName());
}
} else {
v = GlideCacheManager.getPrivateString(this.getName(), this.getValue());
}
if (v == null)
v = "NO CACHE DATA";
this._addBasicResponseText("details", v);
},
_addBasicResponse: function(name, label, value) {
var item = this.newItem();
item.setAttribute("name", name);
item.setAttribute("label", label);
item.setAttribute("value", value);
},
_addBasicResponseText: function(name, value) {
var item = this.newItem();
item.setAttribute("name", name);
item.appendChild(this.getDocument().createTextNode(value));
},
type: "CacheInspectAjax"
});
Sys ID
032d83ff2fee9510bd54d5f62799b6fa