SnapshotEngine extends EngineWrapper { @Override public <A> void update(long recid, A value, Serializer<A> serializer) { locks.lock(recid); try{ Object val = NOT_INIT_YET; for(Snapshot s:snapshots.keySet()){ if(s.oldValues.get(recid)==null){ if(val == NOT_INIT_YET) val = get(recid, serializer); s.oldValues.put(recid,val); } } super.update(recid, value, serializer); }finally{ locks.unlock(recid); } } protected  SnapshotEngine(Engine engine); Engine snapshot(); @Override long put(A value, Serializer<A> serializer); @Override boolean compareAndSwap(long recid, A expectedOldValue, A newValue, Serializer<A> serializer); @Override void update(long recid, A value, Serializer<A> serializer); @Override void delete(long recid, Serializer<A> serializer); static Engine createSnapshotFor(Engine engine);  }
@Test public void update(){ long recid = e.put(111, Serializer.INTEGER_SERIALIZER); Engine snapshot = e.snapshot(); e.update(recid, 222, Serializer.INTEGER_SERIALIZER); assertEquals(Integer.valueOf(111), snapshot.get(recid, Serializer.INTEGER_SERIALIZER)); }