private Object _callCachedWithin(PageContext pc,Collection.Key calledName, Object[] args, Struct values,boolean doIncludePath) throws PageException {
PageContextImpl pci=(PageContextImpl) pc;
String id = UDFUtil.callerHash(this,args,values);
Cache cache = Util.getDefault(pc,ConfigImpl.CACHE_DEFAULT_FUNCTION,DEFAULT_CACHE);
Object o = cache.getValue(id,null);
// get from cache
if(o instanceof UDFCacheEntry ) {
UDFCacheEntry entry = (UDFCacheEntry)o;
//if(entry.creationdate+properties.cachedWithin>=System.currentTimeMillis()) {
try {
pc.write(entry.output);
} catch (IOException e) {
throw Caster.toPageException(e);
}
return entry.returnValue;
//}
//cache.remove(id);
}
// execute the function
BodyContent bc = pci.pushBody();
try {
Object rtn = _call(pci,calledName, args, values, doIncludePath);
String out = bc.getString();
cache.put(id, new UDFCacheEntry(out, rtn),properties.cachedWithin,properties.cachedWithin);
return rtn;
}
finally {
BodyContentUtil.flushAndPop(pc,bc);
}