コード例 #1
0
  public synchronized <A> A fetch(long recid, Serializer<A> serializer) throws IOException {
    checkIfClosed();
    if (_softCache)
      synchronized (_softHash) {
        SoftCacheEntry e = _softHash.get(recid);
        if (e != null) {
          Object a = e.get();
          if (a != null) {
            return (A) a;
          }
        }
      }

    CacheEntry entry = (CacheEntry) cacheGet(recid);
    if (entry == null) {
      A value = _recman.fetch(recid, serializer);
      if (!_softCache) cachePut(recid, value, serializer, false);
      else { // put record into soft cache
        synchronized (_softHash) {
          _softHash.put(recid, new SoftCacheEntry(recid, value, _refQueue));
        }
      }
      return value;
    } else {
      return (A) entry._obj;
    }
  }
コード例 #2
0
 public synchronized <A> A fetch(long recid, Serializer<A> serializer, boolean disableCache)
     throws IOException {
   if (disableCache) return _recman.fetch(recid, serializer, disableCache);
   else return fetch(recid, serializer);
 }