summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--icetray/icetray/abstractCachingDatabaseClient.cpp2
-rw-r--r--icetray/icetray/abstractCachingDatabaseClient.h12
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 <cache.impl.h>
template DLL_PUBLIC void AdHoc::Cache<IceTray::AbstractCachingDatabaseClient::CacheItem, IceTray::AbstractCachingDatabaseClient::CacheKey>::add(const IceTray::AbstractCachingDatabaseClient::CacheKey &, const IceTray::AbstractCachingDatabaseClient::CacheItem &, time_t);
-template DLL_PUBLIC const IceTray::AbstractCachingDatabaseClient::CacheItem * AdHoc::Cache<IceTray::AbstractCachingDatabaseClient::CacheItem, IceTray::AbstractCachingDatabaseClient::CacheKey>::get(const IceTray::AbstractCachingDatabaseClient::CacheKey &) const;
+template DLL_PUBLIC IceTray::AbstractCachingDatabaseClient::Cache::Value AdHoc::Cache<IceTray::AbstractCachingDatabaseClient::CacheItem, IceTray::AbstractCachingDatabaseClient::CacheKey>::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<std::size_t> CacheKey;
- typedef boost::shared_ptr<boost::any> 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<Domain>(cached->get());
- if (d) {
- return *d;
- }
+ return boost::any_cast<Domain>(*cached);
}
auto d(fetch<Domain, Sql, Params...>(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<CacheItem, CacheKey> cache;
+ typedef AdHoc::Cache<CacheItem, CacheKey> Cache;
+ Cache cache;
};
}