public Object get(Object key) { CacheableWrapper retValue = (CacheableWrapper) this.whirlyCache.retrieve(key); if (retValue != null) { if (needRefresh(retValue)) { this.whirlyCacheStatistics.miss(); return null; } this.whirlyCacheStatistics.hit(); } else { this.whirlyCacheStatistics.miss(); return null; } return retValue.getValue(); }
protected boolean needRefresh(CacheableWrapper cacheableWrapper) { if (cacheableWrapper == null) { return true; } if (this.getRefreshTime() == 0) { return false; } boolean result = (System.currentTimeMillis() - cacheableWrapper.getStoredTime()) > (this.getRefreshTime() * 1000); return result; }
public Object remove(Object key) { CacheableWrapper previous = (CacheableWrapper) this.whirlyCache.retrieve(key); this.whirlyCache.remove(key); return previous == null ? null : previous.getValue(); }