From ef2935347099967cc7092fa7f472d91d51571468 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Tue, 24 Feb 2009 00:06:16 +0000 Subject: Whoa, lots of updates. Md5 is more general, nids, cache, cachestore, and cachestorenids all support synchronizing now. Url is pretty much done. --- src/cache.h | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'src/cache.h') diff --git a/src/cache.h b/src/cache.h index ccc4966..036ceb4 100644 --- a/src/cache.h +++ b/src/cache.h @@ -100,6 +100,13 @@ namespace Bu return kId; } + void unbind() + { + if( pCache && pData ) + pCache->decRef( kId ); + pData = NULL; + } + Ptr &operator=( const Ptr &rRhs ) { if( pCache && pData ) @@ -186,6 +193,11 @@ namespace Bu return Ptr( this, pData, k ); } + bool has( const keytype &cId ) + { + return hEnt.has( cId ) || pStore->has( cId ); + } + Ptr get( const keytype &cId ) { TRACE( cId ); @@ -260,6 +272,32 @@ namespace Bu return pStore->getKeys(); } + /** + * Make sure all currently loaded but not-in-use objects are synced to + * the store. + */ + void sync() + { + TRACE(); + int iSynced = 0; + for( typename CidHash::iterator i = hEnt.begin(); + i != hEnt.end(); i++ ) + { + if( i.getValue().iRefs == 0 ) + { + pStore->sync( + i.getValue().pData, + i.getKey() + ); + iSynced++; + } + } + if( iSynced > 0 ) + { + pStore->sync(); + } + } + private: void incRef( const keytype &cId ) { -- cgit v1.2.3