entry = new CacheEntry( recid, null, serializer, false ); entry.obj = recordManager.fetch( recid, serializer );
cache.put( recid, new CacheEntry( recid, obj, serializer, true ) );
if ( entry == null ) entry = new CacheEntry( recid, null, serializer, false ); entry.obj = recMgr.fetch( recid, serializer ); try
cache.put( recid, new CacheEntry( recid, obj, serializer, true ) );
cache.put( recid, new CacheEntry( recid, obj, serializer, true ) );
/** * Place an object in the cache. * @throws IOException */ protected void cachePut(long recid, Object value, Serializer serializer, boolean dirty) throws IOException { CacheEntry entry = _hash.get(recid); if (entry != null) { entry._obj = value; entry._serializer = serializer; touchEntry(entry); } else { if (_hash.size() == _max) { // purge and recycle entry entry = purgeEntry(); entry._recid = recid; entry. _obj = value; entry._isDirty = dirty; entry._serializer = serializer; } else { entry = new CacheEntry(recid, value, serializer,dirty); } addEntry(entry); _hash.put(entry._recid, entry); } }
entry = new CacheEntry( recid, null, serializer, false ); entry.obj = recordManager.fetch( recid, serializer );
/** * Inserts a new record using a custom serializer. * * @param obj the object for the new record. * @param serializer a custom serializer * @return the rowid for the new record. * @throws IOException when one of the underlying I/O operations fails. */ public synchronized long insert( Object obj, Serializer serializer ) throws IOException { checkIfClosed(); long recid = recordManager.insert( obj, serializer ); try { cache.put( recid, new CacheEntry( recid, obj, serializer, false ) ); } catch ( CacheEvictionException except ) { throw new WrappedRuntimeException( except ); } return recid; }
/** * Inserts a new record using a custom serializer. * * @param obj the object for the new record. * @param serializer a custom serializer * @return the rowid for the new record. * @throws IOException when one of the underlying I/O operations fails. */ public synchronized long insert( Object obj, Serializer serializer ) throws IOException { checkIfClosed(); long recid = recMgr.insert( obj, serializer ); try { cache.put( recid, new CacheEntry( recid, obj, serializer, false ) ); } catch ( CacheEvictionException except ) { throw new WrappedRuntimeException( except ); } return recid; }
/** * Inserts a new record using a custom serializer. * * @param obj the object for the new record. * @param serializer a custom serializer * @return the rowid for the new record. * @throws IOException when one of the underlying I/O operations fails. */ public synchronized long insert( Object obj, Serializer serializer ) throws IOException { checkIfClosed(); long recid = recordManager.insert( obj, serializer ); try { cache.put( recid, new CacheEntry( recid, obj, serializer, false ) ); } catch ( CacheEvictionException except ) { throw new WrappedRuntimeException( except ); } return recid; }
/** * Purge least recently used object from the cache * * @return recyclable CacheEntry */ protected CacheEntry purgeEntry() throws IOException { try{ if(disableUpdateCache) throw new InternalError("already inside purging entry"); disableUpdateCache = true; 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; }finally{ disableUpdateCache = false; } }