diff --git a/server/modules/filter/cache/cache.cc b/server/modules/filter/cache/cache.cc index 9d865d2c4..27c0a9245 100644 --- a/server/modules/filter/cache/cache.cc +++ b/server/modules/filter/cache/cache.cc @@ -36,9 +36,11 @@ Cache::~Cache() //static bool Cache::Create(const CACHE_CONFIG& config, - CacheRules** ppRules) + CacheRules** ppRules, + StorageFactory** ppFactory) { CacheRules* pRules = NULL; + StorageFactory* pFactory = NULL; if (config.rules) { @@ -50,26 +52,6 @@ bool Cache::Create(const CACHE_CONFIG& config, } if (pRules) - { - *ppRules = pRules; - } - else - { - MXS_ERROR("Could not create rules."); - } - - return pRules != NULL; -} - -//static -bool Cache::Create(const CACHE_CONFIG& config, - CacheRules** ppRules, - StorageFactory** ppFactory) -{ - CacheRules* pRules = NULL; - StorageFactory* pFactory = NULL; - - if (Create(config, &pRules)) { pFactory = StorageFactory::Open(config.storage); @@ -84,6 +66,10 @@ bool Cache::Create(const CACHE_CONFIG& config, delete pRules; } } + else + { + MXS_ERROR("Could not create rules."); + } return pFactory != NULL; } diff --git a/server/modules/filter/cache/cache.h b/server/modules/filter/cache/cache.h index d6950bb1a..c31465ef7 100644 --- a/server/modules/filter/cache/cache.h +++ b/server/modules/filter/cache/cache.h @@ -84,9 +84,6 @@ protected: SCacheRules sRules, SStorageFactory sFactory); - static bool Create(const CACHE_CONFIG& config, - CacheRules** ppRules); - static bool Create(const CACHE_CONFIG& config, CacheRules** ppRules, StorageFactory** ppFactory); diff --git a/server/modules/filter/cache/cachemt.cc b/server/modules/filter/cache/cachemt.cc index e399346c4..158885370 100644 --- a/server/modules/filter/cache/cachemt.cc +++ b/server/modules/filter/cache/cachemt.cc @@ -54,26 +54,6 @@ CacheMT* CacheMT::Create(const std::string& name, const CACHE_CONFIG* pConfig) return pCache; } -// static -CacheMT* CacheMT::Create(const std::string& name, SStorageFactory sFactory, const CACHE_CONFIG* pConfig) -{ - ss_dassert(pConfig); - ss_dassert(sFactory.get()); - - CacheMT* pCache = NULL; - - CacheRules* pRules = NULL; - - if (CacheSimple::Create(*pConfig, &pRules)) - { - shared_ptr sRules(pRules); - - pCache = Create(name, pConfig, sRules, sFactory); - } - - return pCache; -} - bool CacheMT::must_refresh(const CACHE_KEY& key, const SessionCache* pSessionCache) { LockGuard guard(&m_lockPending); diff --git a/server/modules/filter/cache/cachemt.h b/server/modules/filter/cache/cachemt.h index e2d776e8c..e8b1dfe72 100644 --- a/server/modules/filter/cache/cachemt.h +++ b/server/modules/filter/cache/cachemt.h @@ -22,7 +22,6 @@ public: ~CacheMT(); static CacheMT* Create(const std::string& name, const CACHE_CONFIG* pConfig); - static CacheMT* Create(const std::string& name, SStorageFactory sFactory, const CACHE_CONFIG* pConfig); bool must_refresh(const CACHE_KEY& key, const SessionCache* pSessionCache); diff --git a/server/modules/filter/cache/cachept.cc b/server/modules/filter/cache/cachept.cc index 16a6d2c53..3bfe5d8c5 100644 --- a/server/modules/filter/cache/cachept.cc +++ b/server/modules/filter/cache/cachept.cc @@ -81,27 +81,6 @@ CachePT* CachePT::Create(const std::string& name, const CACHE_CONFIG* pConfig) return pCache; } -// static -CachePT* CachePT::Create(const std::string& name, - SStorageFactory sFactory, - const CACHE_CONFIG* pConfig) -{ - ss_dassert(pConfig); - - CachePT* pCache = NULL; - - CacheRules* pRules = NULL; - - if (Cache::Create(*pConfig, &pRules)) - { - shared_ptr sRules(pRules); - - pCache = Create(name, pConfig, sRules, sFactory); - } - - return pCache; -} - bool CachePT::must_refresh(const CACHE_KEY& key, const SessionCache* pSessionCache) { return thread_cache().must_refresh(key, pSessionCache); @@ -158,7 +137,7 @@ CachePT* CachePT::Create(const std::string& name, CacheST* pCacheST = 0; - CPP_GUARD(pCacheST = CacheST::Create(namest, sFactory, pConfig)); + CPP_GUARD(pCacheST = CacheST::Create(namest, sRules, sFactory, pConfig)); if (pCacheST) { diff --git a/server/modules/filter/cache/cachept.h b/server/modules/filter/cache/cachept.h index 6f035caa7..41d055b5a 100644 --- a/server/modules/filter/cache/cachept.h +++ b/server/modules/filter/cache/cachept.h @@ -23,7 +23,6 @@ public: ~CachePT(); static CachePT* Create(const std::string& name, const CACHE_CONFIG* pConfig); - static CachePT* Create(const std::string& name, SStorageFactory sFactory, const CACHE_CONFIG* pConfig); bool must_refresh(const CACHE_KEY& key, const SessionCache* pSessionCache); diff --git a/server/modules/filter/cache/cachesimple.cc b/server/modules/filter/cache/cachesimple.cc index d80ca4e95..f487db87b 100644 --- a/server/modules/filter/cache/cachesimple.cc +++ b/server/modules/filter/cache/cachesimple.cc @@ -31,23 +31,6 @@ CacheSimple::~CacheSimple() delete m_pStorage; } - -// static -bool CacheSimple::Create(const CACHE_CONFIG& config, - CacheRules** ppRules) -{ - int rv = false; - - CacheRules* pRules = NULL; - - if (Cache::Create(config, &pRules)) - { - *ppRules = pRules; - } - - return pRules != NULL;; -} - // static bool CacheSimple::Create(const CACHE_CONFIG& config, CacheRules** ppRules, diff --git a/server/modules/filter/cache/cachesimple.h b/server/modules/filter/cache/cachesimple.h index 03502c5e1..73a15abf1 100644 --- a/server/modules/filter/cache/cachesimple.h +++ b/server/modules/filter/cache/cachesimple.h @@ -39,9 +39,6 @@ protected: SStorageFactory sFactory, Storage* pStorage); - static bool Create(const CACHE_CONFIG& config, - CacheRules** ppRules); - static bool Create(const CACHE_CONFIG& config, CacheRules** ppRules, StorageFactory** ppFactory); diff --git a/server/modules/filter/cache/cachest.cc b/server/modules/filter/cache/cachest.cc index c569b41ac..f8f75dbb4 100644 --- a/server/modules/filter/cache/cachest.cc +++ b/server/modules/filter/cache/cachest.cc @@ -53,23 +53,16 @@ CacheST* CacheST::Create(const std::string& name, const CACHE_CONFIG* pConfig) } // static -CacheST* CacheST::Create(const std::string& name, SStorageFactory sFactory, const CACHE_CONFIG* pConfig) +CacheST* CacheST::Create(const std::string& name, + SCacheRules sRules, + SStorageFactory sFactory, + const CACHE_CONFIG* pConfig) { - ss_dassert(pConfig); + ss_dassert(sRules.get()); ss_dassert(sFactory.get()); + ss_dassert(pConfig); - CacheST* pCache = NULL; - - CacheRules* pRules = NULL; - - if (CacheSimple::Create(*pConfig, &pRules)) - { - shared_ptr sRules(pRules); - - pCache = Create(name, pConfig, sRules, sFactory); - } - - return pCache; + return Create(name, pConfig, sRules, sFactory); } bool CacheST::must_refresh(const CACHE_KEY& key, const SessionCache* pSessionCache) diff --git a/server/modules/filter/cache/cachest.h b/server/modules/filter/cache/cachest.h index 613d06a10..50f1254ce 100644 --- a/server/modules/filter/cache/cachest.h +++ b/server/modules/filter/cache/cachest.h @@ -21,7 +21,10 @@ public: ~CacheST(); static CacheST* Create(const std::string& name, const CACHE_CONFIG* pConfig); - static CacheST* Create(const std::string& name, SStorageFactory sFactory, const CACHE_CONFIG* pConfig); + static CacheST* Create(const std::string& name, + SCacheRules sRules, + SStorageFactory sFactory, + const CACHE_CONFIG* pConfig); bool must_refresh(const CACHE_KEY& key, const SessionCache* pSessionCache);