/** * Store given item in the cache with a reference to supplied Tridion Item. * * @param key String representing the key to store the cacheItem under * @param cacheElement Object the actual value to store in cache * @param dependingPublicationId int representing the Publication id of the Tridion item the * cacheItem depends on * @param dependingItemId int representing the Item id of the Tridion item the cacheItem * depends on */ @Override public <T> void storeInItemCache(String key, CacheElement<T> cacheElement, int dependingPublicationId, int dependingItemId) { if (!isEnabled()) { return; } CacheDependency dependency = new CacheDependencyImpl(dependingPublicationId, dependingItemId); List<CacheDependency> dependencies = new ArrayList<>(); dependencies.add(dependency); storeInItemCache(key, cacheElement, dependencies); }
/** * 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); }