Cache: All functions now named using snake case
Exception is where the call goes across a plugin boundary, as is the current MaxScale convention.
This commit is contained in:
4
server/modules/filter/cache/cache.cc
vendored
4
server/modules/filter/cache/cache.cc
vendored
@ -90,12 +90,12 @@ bool Cache::Create(const CACHE_CONFIG& config,
|
|||||||
return pFactory != NULL;
|
return pFactory != NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Cache::shouldStore(const char* zDefaultDb, const GWBUF* pQuery)
|
bool Cache::should_store(const char* zDefaultDb, const GWBUF* pQuery)
|
||||||
{
|
{
|
||||||
return cache_rules_should_store(m_pRules, zDefaultDb, pQuery);
|
return cache_rules_should_store(m_pRules, zDefaultDb, pQuery);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Cache::shouldUse(const SESSION* pSession)
|
bool Cache::should_use(const SESSION* pSession)
|
||||||
{
|
{
|
||||||
return cache_rules_should_use(m_pRules, pSession);
|
return cache_rules_should_use(m_pRules, pSession);
|
||||||
}
|
}
|
||||||
|
|||||||
14
server/modules/filter/cache/cache.h
vendored
14
server/modules/filter/cache/cache.h
vendored
@ -36,7 +36,7 @@ public:
|
|||||||
*
|
*
|
||||||
* @return True of the result should be cached.
|
* @return True of the result should be cached.
|
||||||
*/
|
*/
|
||||||
bool shouldStore(const char* zDefaultDb, const GWBUF* pQuery);
|
bool should_store(const char* zDefaultDb, const GWBUF* pQuery);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns whether cached results should be used.
|
* Returns whether cached results should be used.
|
||||||
@ -45,7 +45,7 @@ public:
|
|||||||
*
|
*
|
||||||
* @return True of cached results should be used.
|
* @return True of cached results should be used.
|
||||||
*/
|
*/
|
||||||
bool shouldUse(const SESSION* pSession);
|
bool should_use(const SESSION* pSession);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Specifies whether a particular SessioCache should refresh the data.
|
* Specifies whether a particular SessioCache should refresh the data.
|
||||||
@ -55,7 +55,7 @@ public:
|
|||||||
*
|
*
|
||||||
* @return True, if the session cache should refresh the data.
|
* @return True, if the session cache should refresh the data.
|
||||||
*/
|
*/
|
||||||
virtual bool mustRefresh(const CACHE_KEY& key, const SessionCache* pSessionCache) = 0;
|
virtual bool must_refresh(const CACHE_KEY& key, const SessionCache* pSessionCache) = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* To inform the cache that a particular item has been updated upon request.
|
* To inform the cache that a particular item has been updated upon request.
|
||||||
@ -65,13 +65,13 @@ public:
|
|||||||
*/
|
*/
|
||||||
virtual void refreshed(const CACHE_KEY& key, const SessionCache* pSessionCache) = 0;
|
virtual void refreshed(const CACHE_KEY& key, const SessionCache* pSessionCache) = 0;
|
||||||
|
|
||||||
virtual cache_result_t getKey(const char* zDefaultDb, const GWBUF* pQuery, CACHE_KEY* pKey) = 0;
|
virtual cache_result_t get_key(const char* zDefaultDb, const GWBUF* pQuery, CACHE_KEY* pKey) = 0;
|
||||||
|
|
||||||
virtual cache_result_t getValue(const CACHE_KEY& key, uint32_t flags, GWBUF** ppValue) = 0;
|
virtual cache_result_t get_value(const CACHE_KEY& key, uint32_t flags, GWBUF** ppValue) = 0;
|
||||||
|
|
||||||
virtual cache_result_t putValue(const CACHE_KEY& key, const GWBUF* pValue) = 0;
|
virtual cache_result_t put_value(const CACHE_KEY& key, const GWBUF* pValue) = 0;
|
||||||
|
|
||||||
virtual cache_result_t delValue(const CACHE_KEY& key) = 0;
|
virtual cache_result_t del_value(const CACHE_KEY& key) = 0;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Cache(const std::string& name,
|
Cache(const std::string& name,
|
||||||
|
|||||||
@ -110,7 +110,7 @@ typedef struct cache_storage_api
|
|||||||
* Get a value from the cache.
|
* Get a value from the cache.
|
||||||
*
|
*
|
||||||
* @param storage Pointer to a CACHE_STORAGE.
|
* @param storage Pointer to a CACHE_STORAGE.
|
||||||
* @param key A key generated with getKey.
|
* @param key A key generated with get_key.
|
||||||
* @param flags Mask of cache_flags_t values.
|
* @param flags Mask of cache_flags_t values.
|
||||||
* @param result Pointer to variable that after a successful return will
|
* @param result Pointer to variable that after a successful return will
|
||||||
* point to a GWBUF.
|
* point to a GWBUF.
|
||||||
@ -129,7 +129,7 @@ typedef struct cache_storage_api
|
|||||||
* Put a value to the cache.
|
* Put a value to the cache.
|
||||||
*
|
*
|
||||||
* @param storage Pointer to a CACHE_STORAGE.
|
* @param storage Pointer to a CACHE_STORAGE.
|
||||||
* @param key A key generated with getKey.
|
* @param key A key generated with get_key.
|
||||||
* @param value Pointer to GWBUF containing the value to be stored.
|
* @param value Pointer to GWBUF containing the value to be stored.
|
||||||
* Must be one contiguous buffer.
|
* Must be one contiguous buffer.
|
||||||
* @return CACHE_RESULT_OK if item was successfully put,
|
* @return CACHE_RESULT_OK if item was successfully put,
|
||||||
@ -144,7 +144,7 @@ typedef struct cache_storage_api
|
|||||||
* Delete a value from the cache.
|
* Delete a value from the cache.
|
||||||
*
|
*
|
||||||
* @param storage Pointer to a CACHE_STORAGE.
|
* @param storage Pointer to a CACHE_STORAGE.
|
||||||
* @param key A key generated with getKey.
|
* @param key A key generated with get_key.
|
||||||
* @return CACHE_RESULT_OK if item was successfully deleted. Note that
|
* @return CACHE_RESULT_OK if item was successfully deleted. Note that
|
||||||
* CACHE_RESULT_OK may be returned also if the entry was not present.
|
* CACHE_RESULT_OK may be returned also if the entry was not present.
|
||||||
*/
|
*/
|
||||||
|
|||||||
8
server/modules/filter/cache/cachemt.cc
vendored
8
server/modules/filter/cache/cachemt.cc
vendored
@ -67,12 +67,12 @@ CacheMT* CacheMT::Create(const std::string& name, StorageFactory* pFactory, cons
|
|||||||
return pCache;
|
return pCache;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CacheMT::mustRefresh(const CACHE_KEY& key, const SessionCache* pSessionCache)
|
bool CacheMT::must_refresh(const CACHE_KEY& key, const SessionCache* pSessionCache)
|
||||||
{
|
{
|
||||||
long k = hashOfKey(key);
|
long k = hash_of_key(key);
|
||||||
|
|
||||||
spinlock_acquire(&m_lockPending);
|
spinlock_acquire(&m_lockPending);
|
||||||
bool rv = CacheSimple::mustRefresh(k, pSessionCache);
|
bool rv = CacheSimple::must_refresh(k, pSessionCache);
|
||||||
spinlock_release(&m_lockPending);
|
spinlock_release(&m_lockPending);
|
||||||
|
|
||||||
return rv;
|
return rv;
|
||||||
@ -80,7 +80,7 @@ bool CacheMT::mustRefresh(const CACHE_KEY& key, const SessionCache* pSessionCach
|
|||||||
|
|
||||||
void CacheMT::refreshed(const CACHE_KEY& key, const SessionCache* pSessionCache)
|
void CacheMT::refreshed(const CACHE_KEY& key, const SessionCache* pSessionCache)
|
||||||
{
|
{
|
||||||
long k = hashOfKey(key);
|
long k = hash_of_key(key);
|
||||||
|
|
||||||
spinlock_acquire(&m_lockPending);
|
spinlock_acquire(&m_lockPending);
|
||||||
CacheSimple::refreshed(k, pSessionCache);
|
CacheSimple::refreshed(k, pSessionCache);
|
||||||
|
|||||||
2
server/modules/filter/cache/cachemt.h
vendored
2
server/modules/filter/cache/cachemt.h
vendored
@ -24,7 +24,7 @@ public:
|
|||||||
static CacheMT* Create(const std::string& name, const CACHE_CONFIG* pConfig);
|
static CacheMT* Create(const std::string& name, const CACHE_CONFIG* pConfig);
|
||||||
static CacheMT* Create(const std::string& name, StorageFactory* pFactory, const CACHE_CONFIG* pConfig);
|
static CacheMT* Create(const std::string& name, StorageFactory* pFactory, const CACHE_CONFIG* pConfig);
|
||||||
|
|
||||||
bool mustRefresh(const CACHE_KEY& key, const SessionCache* pSessionCache);
|
bool must_refresh(const CACHE_KEY& key, const SessionCache* pSessionCache);
|
||||||
|
|
||||||
void refreshed(const CACHE_KEY& key, const SessionCache* pSessionCache);
|
void refreshed(const CACHE_KEY& key, const SessionCache* pSessionCache);
|
||||||
|
|
||||||
|
|||||||
24
server/modules/filter/cache/cachept.cc
vendored
24
server/modules/filter/cache/cachept.cc
vendored
@ -95,34 +95,34 @@ CachePT* CachePT::Create(const std::string& name,
|
|||||||
return pCache;
|
return pCache;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CachePT::mustRefresh(const CACHE_KEY& key, const SessionCache* pSessionCache)
|
bool CachePT::must_refresh(const CACHE_KEY& key, const SessionCache* pSessionCache)
|
||||||
{
|
{
|
||||||
return threadCache().mustRefresh(key, pSessionCache);
|
return thread_cache().must_refresh(key, pSessionCache);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CachePT::refreshed(const CACHE_KEY& key, const SessionCache* pSessionCache)
|
void CachePT::refreshed(const CACHE_KEY& key, const SessionCache* pSessionCache)
|
||||||
{
|
{
|
||||||
threadCache().refreshed(key, pSessionCache);
|
thread_cache().refreshed(key, pSessionCache);
|
||||||
}
|
}
|
||||||
|
|
||||||
cache_result_t CachePT::getKey(const char* zDefaultDb, const GWBUF* pQuery, CACHE_KEY* pKey)
|
cache_result_t CachePT::get_key(const char* zDefaultDb, const GWBUF* pQuery, CACHE_KEY* pKey)
|
||||||
{
|
{
|
||||||
return threadCache().getKey(zDefaultDb, pQuery, pKey);
|
return thread_cache().get_key(zDefaultDb, pQuery, pKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
cache_result_t CachePT::getValue(const CACHE_KEY& key, uint32_t flags, GWBUF** ppValue)
|
cache_result_t CachePT::get_value(const CACHE_KEY& key, uint32_t flags, GWBUF** ppValue)
|
||||||
{
|
{
|
||||||
return threadCache().getValue(key, flags, ppValue);
|
return thread_cache().get_value(key, flags, ppValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
cache_result_t CachePT::putValue(const CACHE_KEY& key, const GWBUF* pValue)
|
cache_result_t CachePT::put_value(const CACHE_KEY& key, const GWBUF* pValue)
|
||||||
{
|
{
|
||||||
return threadCache().putValue(key, pValue);
|
return thread_cache().put_value(key, pValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
cache_result_t CachePT::delValue(const CACHE_KEY& key)
|
cache_result_t CachePT::del_value(const CACHE_KEY& key)
|
||||||
{
|
{
|
||||||
return threadCache().delValue(key);
|
return thread_cache().del_value(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
// static
|
// static
|
||||||
@ -181,7 +181,7 @@ CachePT* CachePT::Create(const std::string& name,
|
|||||||
return pCache;
|
return pCache;
|
||||||
}
|
}
|
||||||
|
|
||||||
Cache& CachePT::threadCache()
|
Cache& CachePT::thread_cache()
|
||||||
{
|
{
|
||||||
int i = thread_index();
|
int i = thread_index();
|
||||||
ss_dassert(i < (int)m_caches.size());
|
ss_dassert(i < (int)m_caches.size());
|
||||||
|
|||||||
12
server/modules/filter/cache/cachept.h
vendored
12
server/modules/filter/cache/cachept.h
vendored
@ -25,17 +25,17 @@ public:
|
|||||||
static CachePT* Create(const std::string& name, const CACHE_CONFIG* pConfig);
|
static CachePT* Create(const std::string& name, const CACHE_CONFIG* pConfig);
|
||||||
static CachePT* Create(const std::string& name, StorageFactory* pFactory, const CACHE_CONFIG* pConfig);
|
static CachePT* Create(const std::string& name, StorageFactory* pFactory, const CACHE_CONFIG* pConfig);
|
||||||
|
|
||||||
bool mustRefresh(const CACHE_KEY& key, const SessionCache* pSessionCache);
|
bool must_refresh(const CACHE_KEY& key, const SessionCache* pSessionCache);
|
||||||
|
|
||||||
void refreshed(const CACHE_KEY& key, const SessionCache* pSessionCache);
|
void refreshed(const CACHE_KEY& key, const SessionCache* pSessionCache);
|
||||||
|
|
||||||
cache_result_t getKey(const char* zDefaultDb, const GWBUF* pQuery, CACHE_KEY* pKey);
|
cache_result_t get_key(const char* zDefaultDb, const GWBUF* pQuery, CACHE_KEY* pKey);
|
||||||
|
|
||||||
cache_result_t getValue(const CACHE_KEY& key, uint32_t flags, GWBUF** ppValue);
|
cache_result_t get_value(const CACHE_KEY& key, uint32_t flags, GWBUF** ppValue);
|
||||||
|
|
||||||
cache_result_t putValue(const CACHE_KEY& key, const GWBUF* pValue);
|
cache_result_t put_value(const CACHE_KEY& key, const GWBUF* pValue);
|
||||||
|
|
||||||
cache_result_t delValue(const CACHE_KEY& key);
|
cache_result_t del_value(const CACHE_KEY& key);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
typedef std::tr1::shared_ptr<Cache> SCache;
|
typedef std::tr1::shared_ptr<Cache> SCache;
|
||||||
@ -52,7 +52,7 @@ private:
|
|||||||
CACHE_RULES* pRules,
|
CACHE_RULES* pRules,
|
||||||
StorageFactory* pFactory);
|
StorageFactory* pFactory);
|
||||||
|
|
||||||
Cache& threadCache();
|
Cache& thread_cache();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CachePT(const Cache&);
|
CachePT(const Cache&);
|
||||||
|
|||||||
32
server/modules/filter/cache/cachesimple.cc
vendored
32
server/modules/filter/cache/cachesimple.cc
vendored
@ -129,39 +129,39 @@ bool CacheSimple::Create(const CACHE_CONFIG& config,
|
|||||||
return pPending != NULL;
|
return pPending != NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
cache_result_t CacheSimple::getKey(const char* zDefaultDb,
|
cache_result_t CacheSimple::get_key(const char* zDefaultDb,
|
||||||
const GWBUF* pQuery,
|
const GWBUF* pQuery,
|
||||||
CACHE_KEY* pKey)
|
CACHE_KEY* pKey)
|
||||||
{
|
{
|
||||||
return m_pStorage->getKey(zDefaultDb, pQuery, pKey);
|
return m_pStorage->get_key(zDefaultDb, pQuery, pKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
cache_result_t CacheSimple::getValue(const CACHE_KEY& key,
|
cache_result_t CacheSimple::get_value(const CACHE_KEY& key,
|
||||||
uint32_t flags,
|
uint32_t flags,
|
||||||
GWBUF** ppValue)
|
GWBUF** ppValue)
|
||||||
{
|
{
|
||||||
return m_pStorage->getValue(key, flags, ppValue);
|
return m_pStorage->get_value(key, flags, ppValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
cache_result_t CacheSimple::putValue(const CACHE_KEY& key,
|
cache_result_t CacheSimple::put_value(const CACHE_KEY& key,
|
||||||
const GWBUF* pValue)
|
const GWBUF* pValue)
|
||||||
{
|
{
|
||||||
return m_pStorage->putValue(key, pValue);
|
return m_pStorage->put_value(key, pValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
cache_result_t CacheSimple::delValue(const CACHE_KEY& key)
|
cache_result_t CacheSimple::del_value(const CACHE_KEY& key)
|
||||||
{
|
{
|
||||||
return m_pStorage->delValue(key);
|
return m_pStorage->del_value(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
// protected
|
// protected
|
||||||
long CacheSimple::hashOfKey(const CACHE_KEY& key)
|
long CacheSimple::hash_of_key(const CACHE_KEY& key)
|
||||||
{
|
{
|
||||||
return hash_of_key(key);
|
return ::hash_of_key(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
// protected
|
// protected
|
||||||
bool CacheSimple::mustRefresh(long key, const SessionCache* pSessionCache)
|
bool CacheSimple::must_refresh(long key, const SessionCache* pSessionCache)
|
||||||
{
|
{
|
||||||
void *pValue = hashtable_fetch(m_pPending, (void*)key);
|
void *pValue = hashtable_fetch(m_pPending, (void*)key);
|
||||||
if (!pValue)
|
if (!pValue)
|
||||||
|
|||||||
12
server/modules/filter/cache/cachesimple.h
vendored
12
server/modules/filter/cache/cachesimple.h
vendored
@ -23,13 +23,13 @@ class CacheSimple : public Cache
|
|||||||
public:
|
public:
|
||||||
~CacheSimple();
|
~CacheSimple();
|
||||||
|
|
||||||
cache_result_t getKey(const char* zDefaultDb, const GWBUF* pQuery, CACHE_KEY* pKey);
|
cache_result_t get_key(const char* zDefaultDb, const GWBUF* pQuery, CACHE_KEY* pKey);
|
||||||
|
|
||||||
cache_result_t getValue(const CACHE_KEY& key, uint32_t flags, GWBUF** ppValue);
|
cache_result_t get_value(const CACHE_KEY& key, uint32_t flags, GWBUF** ppValue);
|
||||||
|
|
||||||
cache_result_t putValue(const CACHE_KEY& key, const GWBUF* pValue);
|
cache_result_t put_value(const CACHE_KEY& key, const GWBUF* pValue);
|
||||||
|
|
||||||
cache_result_t delValue(const CACHE_KEY& key);
|
cache_result_t del_value(const CACHE_KEY& key);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
CacheSimple(const std::string& name,
|
CacheSimple(const std::string& name,
|
||||||
@ -49,9 +49,9 @@ protected:
|
|||||||
StorageFactory** ppFactory);
|
StorageFactory** ppFactory);
|
||||||
|
|
||||||
|
|
||||||
long hashOfKey(const CACHE_KEY& key);
|
long hash_of_key(const CACHE_KEY& key);
|
||||||
|
|
||||||
bool mustRefresh(long key, const SessionCache* pSessionCache);
|
bool must_refresh(long key, const SessionCache* pSessionCache);
|
||||||
|
|
||||||
void refreshed(long key, const SessionCache* pSessionCache);
|
void refreshed(long key, const SessionCache* pSessionCache);
|
||||||
|
|
||||||
|
|||||||
10
server/modules/filter/cache/cachest.cc
vendored
10
server/modules/filter/cache/cachest.cc
vendored
@ -66,21 +66,21 @@ CacheST* CacheST::Create(const std::string& name, StorageFactory* pFactory, cons
|
|||||||
return pCache;
|
return pCache;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CacheST::mustRefresh(const CACHE_KEY& key, const SessionCache* pSessionCache)
|
bool CacheST::must_refresh(const CACHE_KEY& key, const SessionCache* pSessionCache)
|
||||||
{
|
{
|
||||||
long k = hashOfKey(key);
|
long k = hash_of_key(key);
|
||||||
|
|
||||||
return CacheSimple::mustRefresh(k, pSessionCache);
|
return CacheSimple::must_refresh(k, pSessionCache);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CacheST::refreshed(const CACHE_KEY& key, const SessionCache* pSessionCache)
|
void CacheST::refreshed(const CACHE_KEY& key, const SessionCache* pSessionCache)
|
||||||
{
|
{
|
||||||
long k = hashOfKey(key);
|
long k = hash_of_key(key);
|
||||||
|
|
||||||
CacheSimple::refreshed(k, pSessionCache);
|
CacheSimple::refreshed(k, pSessionCache);
|
||||||
}
|
}
|
||||||
|
|
||||||
// statis
|
// static
|
||||||
CacheST* CacheST::Create(const std::string& name,
|
CacheST* CacheST::Create(const std::string& name,
|
||||||
const CACHE_CONFIG* pConfig,
|
const CACHE_CONFIG* pConfig,
|
||||||
CACHE_RULES* pRules,
|
CACHE_RULES* pRules,
|
||||||
|
|||||||
2
server/modules/filter/cache/cachest.h
vendored
2
server/modules/filter/cache/cachest.h
vendored
@ -23,7 +23,7 @@ public:
|
|||||||
static CacheST* Create(const std::string& name, const CACHE_CONFIG* pConfig);
|
static CacheST* Create(const std::string& name, const CACHE_CONFIG* pConfig);
|
||||||
static CacheST* Create(const std::string& name, StorageFactory* pFactory, const CACHE_CONFIG* pConfig);
|
static CacheST* Create(const std::string& name, StorageFactory* pFactory, const CACHE_CONFIG* pConfig);
|
||||||
|
|
||||||
bool mustRefresh(const CACHE_KEY& key, const SessionCache* pSessionCache);
|
bool must_refresh(const CACHE_KEY& key, const SessionCache* pSessionCache);
|
||||||
|
|
||||||
void refreshed(const CACHE_KEY& key, const SessionCache* pSessionCache);
|
void refreshed(const CACHE_KEY& key, const SessionCache* pSessionCache);
|
||||||
|
|
||||||
|
|||||||
14
server/modules/filter/cache/sessioncache.cc
vendored
14
server/modules/filter/cache/sessioncache.cc
vendored
@ -138,9 +138,9 @@ int SessionCache::routeQuery(GWBUF* pPacket)
|
|||||||
if ((session_is_autocommit(session) && !session_trx_is_active(session)) ||
|
if ((session_is_autocommit(session) && !session_trx_is_active(session)) ||
|
||||||
session_trx_is_read_only(session))
|
session_trx_is_read_only(session))
|
||||||
{
|
{
|
||||||
if (m_pCache->shouldStore(m_zDefaultDb, pPacket))
|
if (m_pCache->should_store(m_zDefaultDb, pPacket))
|
||||||
{
|
{
|
||||||
if (m_pCache->shouldUse(m_pSession))
|
if (m_pCache->should_use(m_pSession))
|
||||||
{
|
{
|
||||||
GWBUF* pResponse;
|
GWBUF* pResponse;
|
||||||
cache_result_t result = get_cached_response(pPacket, &pResponse);
|
cache_result_t result = get_cached_response(pPacket, &pResponse);
|
||||||
@ -152,7 +152,7 @@ int SessionCache::routeQuery(GWBUF* pPacket)
|
|||||||
// The value was found, but it was stale. Now we need to
|
// The value was found, but it was stale. Now we need to
|
||||||
// figure out whether somebody else is already fetching it.
|
// figure out whether somebody else is already fetching it.
|
||||||
|
|
||||||
if (m_pCache->mustRefresh(m_key, this))
|
if (m_pCache->must_refresh(m_key, this))
|
||||||
{
|
{
|
||||||
// We were the first ones who hit the stale item. It's
|
// We were the first ones who hit the stale item. It's
|
||||||
// our responsibility now to fetch it.
|
// our responsibility now to fetch it.
|
||||||
@ -607,13 +607,13 @@ void SessionCache::reset_response_state()
|
|||||||
*/
|
*/
|
||||||
cache_result_t SessionCache::get_cached_response(const GWBUF *pQuery, GWBUF **ppResponse)
|
cache_result_t SessionCache::get_cached_response(const GWBUF *pQuery, GWBUF **ppResponse)
|
||||||
{
|
{
|
||||||
cache_result_t result = m_pCache->getKey(m_zDefaultDb, pQuery, &m_key);
|
cache_result_t result = m_pCache->get_key(m_zDefaultDb, pQuery, &m_key);
|
||||||
|
|
||||||
if (result == CACHE_RESULT_OK)
|
if (result == CACHE_RESULT_OK)
|
||||||
{
|
{
|
||||||
uint32_t flags = CACHE_FLAGS_INCLUDE_STALE;
|
uint32_t flags = CACHE_FLAGS_INCLUDE_STALE;
|
||||||
|
|
||||||
result = m_pCache->getValue(m_key, flags, ppResponse);
|
result = m_pCache->get_value(m_key, flags, ppResponse);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -638,13 +638,13 @@ void SessionCache::store_result()
|
|||||||
{
|
{
|
||||||
m_res.pData = pData;
|
m_res.pData = pData;
|
||||||
|
|
||||||
cache_result_t result = m_pCache->putValue(m_key, m_res.pData);
|
cache_result_t result = m_pCache->put_value(m_key, m_res.pData);
|
||||||
|
|
||||||
if (result != CACHE_RESULT_OK)
|
if (result != CACHE_RESULT_OK)
|
||||||
{
|
{
|
||||||
MXS_ERROR("Could not store cache item, deleting it.");
|
MXS_ERROR("Could not store cache item, deleting it.");
|
||||||
|
|
||||||
result = m_pCache->delValue(m_key);
|
result = m_pCache->del_value(m_key);
|
||||||
|
|
||||||
if ((result != CACHE_RESULT_OK) || (result != CACHE_RESULT_NOT_FOUND))
|
if ((result != CACHE_RESULT_OK) || (result != CACHE_RESULT_NOT_FOUND))
|
||||||
{
|
{
|
||||||
|
|||||||
18
server/modules/filter/cache/storage.cc
vendored
18
server/modules/filter/cache/storage.cc
vendored
@ -27,27 +27,27 @@ Storage::~Storage()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
cache_result_t Storage::getKey(const char* zDefaultDb,
|
cache_result_t Storage::get_key(const char* zDefaultDb,
|
||||||
const GWBUF* pQuery,
|
const GWBUF* pQuery,
|
||||||
CACHE_KEY* pKey)
|
CACHE_KEY* pKey)
|
||||||
{
|
{
|
||||||
return m_pApi->getKey(m_pStorage, zDefaultDb, pQuery, pKey);
|
return m_pApi->getKey(m_pStorage, zDefaultDb, pQuery, pKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
cache_result_t Storage::getValue(const CACHE_KEY& key,
|
cache_result_t Storage::get_value(const CACHE_KEY& key,
|
||||||
uint32_t flags,
|
uint32_t flags,
|
||||||
GWBUF** ppValue)
|
GWBUF** ppValue)
|
||||||
{
|
{
|
||||||
return m_pApi->getValue(m_pStorage, &key, flags, ppValue);
|
return m_pApi->getValue(m_pStorage, &key, flags, ppValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
cache_result_t Storage::putValue(const CACHE_KEY& key,
|
cache_result_t Storage::put_value(const CACHE_KEY& key,
|
||||||
const GWBUF* pValue)
|
const GWBUF* pValue)
|
||||||
{
|
{
|
||||||
return m_pApi->putValue(m_pStorage, &key, pValue);
|
return m_pApi->putValue(m_pStorage, &key, pValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
cache_result_t Storage::delValue(const CACHE_KEY& key)
|
cache_result_t Storage::del_value(const CACHE_KEY& key)
|
||||||
{
|
{
|
||||||
return m_pApi->delValue(m_pStorage, &key);
|
return m_pApi->delValue(m_pStorage, &key);
|
||||||
}
|
}
|
||||||
|
|||||||
8
server/modules/filter/cache/storage.h
vendored
8
server/modules/filter/cache/storage.h
vendored
@ -22,18 +22,18 @@ class Storage
|
|||||||
public:
|
public:
|
||||||
~Storage();
|
~Storage();
|
||||||
|
|
||||||
cache_result_t getKey(const char* zDefaultDb,
|
cache_result_t get_key(const char* zDefaultDb,
|
||||||
const GWBUF* pQuery,
|
const GWBUF* pQuery,
|
||||||
CACHE_KEY* pKey);
|
CACHE_KEY* pKey);
|
||||||
|
|
||||||
cache_result_t getValue(const CACHE_KEY& key,
|
cache_result_t get_value(const CACHE_KEY& key,
|
||||||
uint32_t flags,
|
uint32_t flags,
|
||||||
GWBUF** ppValue);
|
GWBUF** ppValue);
|
||||||
|
|
||||||
cache_result_t putValue(const CACHE_KEY& key,
|
cache_result_t put_value(const CACHE_KEY& key,
|
||||||
const GWBUF* pValue);
|
const GWBUF* pValue);
|
||||||
|
|
||||||
cache_result_t delValue(const CACHE_KEY& key);
|
cache_result_t del_value(const CACHE_KEY& key);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend class StorageFactory;
|
friend class StorageFactory;
|
||||||
|
|||||||
Reference in New Issue
Block a user