aboutsummaryrefslogtreecommitdiff
path: root/src/unstable
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2013-03-18 15:31:39 +0000
committerMike Buland <eichlan@xagasoft.com>2013-03-18 15:31:39 +0000
commit92a6325b02d2a41d7c36993f7b230302f672a4ba (patch)
tree284589448762ec002adc8ee3127342acd1bd409d /src/unstable
parent1db266b863a805d49928d831a690c39df640dc28 (diff)
downloadlibbu++-92a6325b02d2a41d7c36993f7b230302f672a4ba.tar.gz
libbu++-92a6325b02d2a41d7c36993f7b230302f672a4ba.tar.bz2
libbu++-92a6325b02d2a41d7c36993f7b230302f672a4ba.tar.xz
libbu++-92a6325b02d2a41d7c36993f7b230302f672a4ba.zip
Added the has function to the new cache system. If the object identified by
key is loaded then the query doesn't even get to the superclass.
Diffstat (limited to 'src/unstable')
-rw-r--r--src/unstable/cachebase.h11
-rw-r--r--src/unstable/myriadcache.h6
2 files changed, 17 insertions, 0 deletions
diff --git a/src/unstable/cachebase.h b/src/unstable/cachebase.h
index 807adf0..026e69b 100644
--- a/src/unstable/cachebase.h
+++ b/src/unstable/cachebase.h
@@ -350,6 +350,16 @@ namespace Bu
350 ); 350 );
351 } 351 }
352 352
353 bool has( const keytype &key )
354 {
355 Bu::ReadWriteMutex::ReadLocker rl( mCacheEntry );
356
357 if( hCacheEntry.has( key ) )
358 return true;
359
360 return _has( key );
361 }
362
353 CachePtr<keytype, obtype> get( const keytype &key ) 363 CachePtr<keytype, obtype> get( const keytype &key )
354 { 364 {
355 Entry *pEnt = getEntry( key ); 365 Entry *pEnt = getEntry( key );
@@ -431,6 +441,7 @@ namespace Bu
431 } 441 }
432 442
433 protected: 443 protected:
444 virtual bool _has( const keytype &key )=0;
434 virtual void _create( const obtype *o )=0; 445 virtual void _create( const obtype *o )=0;
435 virtual void _erase( const keytype &k )=0; 446 virtual void _erase( const keytype &k )=0;
436 447
diff --git a/src/unstable/myriadcache.h b/src/unstable/myriadcache.h
index 7ff2183..7f83250 100644
--- a/src/unstable/myriadcache.h
+++ b/src/unstable/myriadcache.h
@@ -68,6 +68,12 @@ namespace Bu
68 } 68 }
69 69
70 protected: 70 protected:
71 virtual bool _has( const keytype &key )
72 {
73 Bu::ReadWriteMutex::ReadLocker rl( rwStore );
74 return hIndex.has( key );
75 }
76
71 virtual void _create( const obtype *o ) 77 virtual void _create( const obtype *o )
72 { 78 {
73 Bu::ReadWriteMutex::WriteLocker wl( rwStore ); 79 Bu::ReadWriteMutex::WriteLocker wl( rwStore );