From 65cc54be0a14e627938731ff8deefea61c2c1cfa Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Wed, 3 Jul 2013 19:55:56 +0000 Subject: Modified the Bu::CacheBase API, what was erase is eraseNow, and erase is about to be re-engineered to actually do a lazy erase like removing an iNode in a posix filesystem. While the file remains open it exists, but the references visible to the user on disk are gone. --- src/unstable/cachebase.h | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'src/unstable') diff --git a/src/unstable/cachebase.h b/src/unstable/cachebase.h index 270c2df..6cc3e77 100644 --- a/src/unstable/cachebase.h +++ b/src/unstable/cachebase.h @@ -393,7 +393,26 @@ namespace Bu return CachePtr( this, ptr.kId ); } + /** + * Removes an item from the cache. + * This routine calls eraseNow for now. Later the intention is that + * this function will always succeed. It will remove the object from + * the backing store and the active tables. It will not be able to + * be requested again, and all changes will be ignored. When the + * object's last references are released the memory will be freed + * automatically. + */ void erase( const keytype &key ) + { + eraseNow( key ); + } + + /** + * Removes an item from the cache and frees memory immediately. + * The object in question cannot have any active references in order + * for this to succeed, otherwise it will throw an exception. + */ + void eraseNow( const keytype &key ) { Bu::ReadWriteMutex::WriteLocker wl( mCacheEntry ); if( hCacheEntry.has( key ) ) @@ -456,6 +475,8 @@ namespace Bu Entry *pEnt = new Entry( pObject ); mCacheEntry.lockWrite(); hCacheEntry.insert( pObject->getKey(), pEnt ); + if( pObject->hasChanged() ) + hChanged.insert( pObject->getKey(), true ); mCacheEntry.unlockWrite(); _create( pObject ); pObject->setCache( this, pEnt ); -- cgit v1.2.3