Cache: Now also CacheRules is shared
Unnecessary methods were also removed from CachePT and CacheMT as it does not make sense to create more than one single instance of those per filter instance. Consequently there is no need for them to be able to use an existing StorageFactory (and CacheRules).
This commit is contained in:
28
server/modules/filter/cache/cache.cc
vendored
28
server/modules/filter/cache/cache.cc
vendored
@ -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;
|
||||
}
|
||||
|
||||
3
server/modules/filter/cache/cache.h
vendored
3
server/modules/filter/cache/cache.h
vendored
@ -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);
|
||||
|
||||
20
server/modules/filter/cache/cachemt.cc
vendored
20
server/modules/filter/cache/cachemt.cc
vendored
@ -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<CacheRules> 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);
|
||||
|
||||
1
server/modules/filter/cache/cachemt.h
vendored
1
server/modules/filter/cache/cachemt.h
vendored
@ -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);
|
||||
|
||||
|
||||
23
server/modules/filter/cache/cachept.cc
vendored
23
server/modules/filter/cache/cachept.cc
vendored
@ -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<CacheRules> 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)
|
||||
{
|
||||
|
||||
1
server/modules/filter/cache/cachept.h
vendored
1
server/modules/filter/cache/cachept.h
vendored
@ -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);
|
||||
|
||||
|
||||
17
server/modules/filter/cache/cachesimple.cc
vendored
17
server/modules/filter/cache/cachesimple.cc
vendored
@ -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,
|
||||
|
||||
3
server/modules/filter/cache/cachesimple.h
vendored
3
server/modules/filter/cache/cachesimple.h
vendored
@ -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);
|
||||
|
||||
21
server/modules/filter/cache/cachest.cc
vendored
21
server/modules/filter/cache/cachest.cc
vendored
@ -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<CacheRules> 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)
|
||||
|
||||
5
server/modules/filter/cache/cachest.h
vendored
5
server/modules/filter/cache/cachest.h
vendored
@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user