summaryrefslogtreecommitdiff
path: root/src/unstable/cachebase.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/unstable/cachebase.h')
-rw-r--r--src/unstable/cachebase.h21
1 files changed, 21 insertions, 0 deletions
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,8 +393,27 @@ namespace Bu
393 return CachePtr<keytype, castto, obtype>( this, ptr.kId ); 393 return CachePtr<keytype, castto, obtype>( this, ptr.kId );
394 } 394 }
395 395
396 /**
397 * Removes an item from the cache.
398 * This routine calls eraseNow for now. Later the intention is that
399 * this function will always succeed. It will remove the object from
400 * the backing store and the active tables. It will not be able to
401 * be requested again, and all changes will be ignored. When the
402 * object's last references are released the memory will be freed
403 * automatically.
404 */
396 void erase( const keytype &key ) 405 void erase( const keytype &key )
397 { 406 {
407 eraseNow( key );
408 }
409
410 /**
411 * Removes an item from the cache and frees memory immediately.
412 * The object in question cannot have any active references in order
413 * for this to succeed, otherwise it will throw an exception.
414 */
415 void eraseNow( const keytype &key )
416 {
398 Bu::ReadWriteMutex::WriteLocker wl( mCacheEntry ); 417 Bu::ReadWriteMutex::WriteLocker wl( mCacheEntry );
399 if( hCacheEntry.has( key ) ) 418 if( hCacheEntry.has( key ) )
400 { 419 {
@@ -456,6 +475,8 @@ namespace Bu
456 Entry *pEnt = new Entry( pObject ); 475 Entry *pEnt = new Entry( pObject );
457 mCacheEntry.lockWrite(); 476 mCacheEntry.lockWrite();
458 hCacheEntry.insert( pObject->getKey(), pEnt ); 477 hCacheEntry.insert( pObject->getKey(), pEnt );
478 if( pObject->hasChanged() )
479 hChanged.insert( pObject->getKey(), true );
459 mCacheEntry.unlockWrite(); 480 mCacheEntry.unlockWrite();
460 _create( pObject ); 481 _create( pObject );
461 pObject->setCache( this, pEnt ); 482 pObject->setCache( this, pEnt );