/** * Store given item in the cache with a simple time-to-live property. * * @param key String representing the key to store the payload under * @param cacheElement CacheElement a wrapper around the actual value to store in * cache */ @Override public <T> void storeInItemCache(String key, CacheElement<T> cacheElement) { if (!isEnabled()) { return; } if (!cacheExists()) { LOG.error("Cache configuration is invalid! NOT Caching. Check EH Cache configuration."); return; } // detect undeclared nulls, complain, and set to null if (!cacheElement.isNull() && cacheElement.getPayload() == null) { Exception exToLogToHaveStacktraceWhoCausedIt = new Exception(); LOG.error("Detected undeclared null payload on element with key " + key + " at insert time!", exToLogToHaveStacktraceWhoCausedIt); cacheElement.setNull(true); } cacheElement.setExpired(false); storeElement(key, cacheElement); }
@Override public <T> void storeInItemCache(String key, CacheElement<T> cacheElement, List<CacheDependency> dependencies) { if (!isEnabled()) { return; } if (!cacheExists()) { LOG.error("Cache configuration is invalid! NOT Caching. Check EH Cache configuration."); return; } // detect undeclared nulls, complain, and set to null if (!cacheElement.isNull() && cacheElement.getPayload() == null) { Exception exToLogToHaveStacktraceWhoCausedIt = new Exception(); LOG.error("Detected undeclared null payload on element with key " + key + " at insert time!", exToLogToHaveStacktraceWhoCausedIt); cacheElement.setNull(true); } cacheElement.setExpired(false); Element element = cache.get(key); if (element == null) { element = new Element(key, cacheElement); } cache.put(element); element.setTimeToLive(cacheDependencyTTL); for (CacheDependency dep : dependencies) { String dependentKey = getKey(dep.getPublicationId(), dep.getItemId()); cacheElement.setDependentKey(dependentKey); addDependency(key, dependentKey); updateTTL(dependencyCache.get(dependentKey)); } }
cacheElement.setNull(true); cacheProvider.storeInItemCache(uri, cacheElement); throw new ItemNotFoundException("Unable to find page by id " + uri);
@Override public <T> void storeInItemCache(final String key, final CacheElement<T> cacheElement, final List<CacheDependency> dependencies) { if (!isEnabled()) { return; } if (!cacheExists()) { LOG.error("Cache configuration is invalid! NOT Caching. Check EH Cache configuration."); return; } // detect undeclared nulls, complain, and set to null if (!cacheElement.isNull() && cacheElement.getPayload() == null) { Exception exToLogToHaveStacktraceWhoCausedIt = new Exception(); LOG.error("Detected undeclared null payload on element with key " + key + " at insert time!", exToLogToHaveStacktraceWhoCausedIt); cacheElement.setNull(true); cacheElement.setExpired(true); } cacheElement.setExpired(false); if (cache.containsKey(key)) { cache.replace(key, cacheElement); } else { cache.put(key, cacheElement); } for (CacheDependency dep : dependencies) { String dependentKey = getKey(dep.getPublicationId(), dep.getItemId()); cacheElement.setDependentKey(dependentKey); addDependency(key, dependentKey); } }
cacheElement.setNull(true); cacheProvider.storeInItemCache(key, cacheElement, publicationId, componentId); throw new ItemNotFoundException(String.format("Could not find DCP with componentURI: %s and " +