summaryrefslogtreecommitdiff
path: root/src/cache.h
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2009-02-24 00:06:16 +0000
committerMike Buland <eichlan@xagasoft.com>2009-02-24 00:06:16 +0000
commitef2935347099967cc7092fa7f472d91d51571468 (patch)
treeabf0c041a31610fa7f8fb562c3c36a8277c438d2 /src/cache.h
parent4309066dff46f52690998bbd1f60ec8b1631f142 (diff)
downloadlibbu++-ef2935347099967cc7092fa7f472d91d51571468.tar.gz
libbu++-ef2935347099967cc7092fa7f472d91d51571468.tar.bz2
libbu++-ef2935347099967cc7092fa7f472d91d51571468.tar.xz
libbu++-ef2935347099967cc7092fa7f472d91d51571468.zip
Whoa, lots of updates. Md5 is more general, nids, cache, cachestore, and
cachestorenids all support synchronizing now. Url is pretty much done.
Diffstat (limited to 'src/cache.h')
-rw-r--r--src/cache.h38
1 files changed, 38 insertions, 0 deletions
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
100 return kId; 100 return kId;
101 } 101 }
102 102
103 void unbind()
104 {
105 if( pCache && pData )
106 pCache->decRef( kId );
107 pData = NULL;
108 }
109
103 Ptr &operator=( const Ptr &rRhs ) 110 Ptr &operator=( const Ptr &rRhs )
104 { 111 {
105 if( pCache && pData ) 112 if( pCache && pData )
@@ -186,6 +193,11 @@ namespace Bu
186 return Ptr( this, pData, k ); 193 return Ptr( this, pData, k );
187 } 194 }
188 195
196 bool has( const keytype &cId )
197 {
198 return hEnt.has( cId ) || pStore->has( cId );
199 }
200
189 Ptr get( const keytype &cId ) 201 Ptr get( const keytype &cId )
190 { 202 {
191 TRACE( cId ); 203 TRACE( cId );
@@ -260,6 +272,32 @@ namespace Bu
260 return pStore->getKeys(); 272 return pStore->getKeys();
261 } 273 }
262 274
275 /**
276 * Make sure all currently loaded but not-in-use objects are synced to
277 * the store.
278 */
279 void sync()
280 {
281 TRACE();
282 int iSynced = 0;
283 for( typename CidHash::iterator i = hEnt.begin();
284 i != hEnt.end(); i++ )
285 {
286 if( i.getValue().iRefs == 0 )
287 {
288 pStore->sync(
289 i.getValue().pData,
290 i.getKey()
291 );
292 iSynced++;
293 }
294 }
295 if( iSynced > 0 )
296 {
297 pStore->sync();
298 }
299 }
300
263 private: 301 private:
264 void incRef( const keytype &cId ) 302 void incRef( const keytype &cId )
265 { 303 {