From 92a6325b02d2a41d7c36993f7b230302f672a4ba Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Mon, 18 Mar 2013 15:31:39 +0000 Subject: 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. --- src/unstable/cachebase.h | 11 +++++++++++ src/unstable/myriadcache.h | 6 ++++++ 2 files changed, 17 insertions(+) (limited to 'src/unstable') 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 ); } + bool has( const keytype &key ) + { + Bu::ReadWriteMutex::ReadLocker rl( mCacheEntry ); + + if( hCacheEntry.has( key ) ) + return true; + + return _has( key ); + } + CachePtr get( const keytype &key ) { Entry *pEnt = getEntry( key ); @@ -431,6 +441,7 @@ namespace Bu } protected: + virtual bool _has( const keytype &key )=0; virtual void _create( const obtype *o )=0; virtual void _erase( const keytype &k )=0; 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 } protected: + virtual bool _has( const keytype &key ) + { + Bu::ReadWriteMutex::ReadLocker rl( rwStore ); + return hIndex.has( key ); + } + virtual void _create( const obtype *o ) { Bu::ReadWriteMutex::WriteLocker wl( rwStore ); -- cgit v1.2.3