Esempio n. 1
0
 /** Update all dirty cache objects to the underlying RecordManager. */
 protected void updateCacheEntries() throws IOException {
   Iterator<CacheEntry> iter = _hash.valuesIterator();
   while (iter.hasNext()) {
     CacheEntry entry = iter.next();
     if (entry._isDirty) {
       _recman.update(entry._recid, entry._obj, entry._serializer);
       entry._isDirty = false;
     }
   }
 }
Esempio n. 2
0
  /**
   * Purge least recently used object from the cache
   *
   * @return recyclable CacheEntry
   */
  protected CacheEntry purgeEntry() throws IOException {
    CacheEntry entry = _first;
    if (entry == null) return new CacheEntry(-1, null, null, false);

    if (entry._isDirty) _recman.update(entry._recid, entry._obj, entry._serializer);
    removeEntry(entry);
    _hash.remove(entry._recid);

    entry._obj = null;
    entry._serializer = null;
    entry._isDirty = false;
    return entry;
  }