Example #1
0
 public V value(K key) {
   CacheItem<K, V> item = item(key);
   if (item != null) {
     if (item.isValid()) {
       return item.getValue();
     } else {
       invalidate(key);
       return null;
     }
   } else {
     return null;
   }
 }
Example #2
0
  public Object get(String url, boolean checkExpiration) {
    Timber.d(String.format("get(%s)", url));
    CacheItem result;

    // First try Memory Cache
    result = getFromMemoryCache(url, checkExpiration);

    if (null == result) {
      // Memory Cache failed, so try Disk Cache
      result = getFromDiskCache(url, checkExpiration);
    }

    if (result != null) {
      return result.getValue();
    } else {
      return null;
    }
  }