Ejemplo n.º 1
0
  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();
  }
Ejemplo n.º 2
0
 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;
 }
Ejemplo n.º 3
0
 public Object remove(Object key) {
   CacheableWrapper previous = (CacheableWrapper) this.whirlyCache.retrieve(key);
   this.whirlyCache.remove(key);
   return previous == null ? null : previous.getValue();
 }