From 4353c88b1702ebf325ee011764812d2cbaa15ae5 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Tue, 5 Jan 2016 21:47:00 +0000 Subject: Update to use new AdHoc::Cache interface --- icetray/icetray/abstractCachingDatabaseClient.cpp | 2 +- icetray/icetray/abstractCachingDatabaseClient.h | 12 +++++------- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/icetray/icetray/abstractCachingDatabaseClient.cpp b/icetray/icetray/abstractCachingDatabaseClient.cpp index 2c97ac6..c05b700 100644 --- a/icetray/icetray/abstractCachingDatabaseClient.cpp +++ b/icetray/icetray/abstractCachingDatabaseClient.cpp @@ -2,7 +2,7 @@ #include template DLL_PUBLIC void AdHoc::Cache::add(const IceTray::AbstractCachingDatabaseClient::CacheKey &, const IceTray::AbstractCachingDatabaseClient::CacheItem &, time_t); -template DLL_PUBLIC const IceTray::AbstractCachingDatabaseClient::CacheItem * AdHoc::Cache::get(const IceTray::AbstractCachingDatabaseClient::CacheKey &) const; +template DLL_PUBLIC IceTray::AbstractCachingDatabaseClient::Cache::Value AdHoc::Cache::get(const IceTray::AbstractCachingDatabaseClient::CacheKey &) const; namespace IceTray { AbstractCachingDatabaseClient::AbstractCachingDatabaseClient(DatabasePoolPtr d) : diff --git a/icetray/icetray/abstractCachingDatabaseClient.h b/icetray/icetray/abstractCachingDatabaseClient.h index cdf0a91..fd67e03 100644 --- a/icetray/icetray/abstractCachingDatabaseClient.h +++ b/icetray/icetray/abstractCachingDatabaseClient.h @@ -10,7 +10,7 @@ namespace IceTray { class DLL_PUBLIC AbstractCachingDatabaseClient : public AbstractDatabaseClient { private: typedef std::vector CacheKey; - typedef boost::shared_ptr CacheItem; + typedef boost::any CacheItem; public: AbstractCachingDatabaseClient(DatabasePoolPtr d); @@ -26,13 +26,10 @@ namespace IceTray { key.push_back(typeid(Domain).hash_code()); keyPushParams(key, params...); if (auto cached = cache.get(key)) { - auto d = boost::any_cast(cached->get()); - if (d) { - return *d; - } + return boost::any_cast(*cached); } auto d(fetch(params...)); - cache.add(key, CacheItem(new boost::any(d)), time(NULL) + cacheTime); + cache.add(key, CacheItem(d), time(NULL) + cacheTime); return d; } @@ -46,7 +43,8 @@ namespace IceTray { static void keyPushParams(CacheKey &); - AdHoc::Cache cache; + typedef AdHoc::Cache Cache; + Cache cache; }; } -- cgit v1.2.3