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:
Johan Wikman 2016-11-28 09:47:53 +02:00
parent a2daacd465
commit 02265c5dc2
14 changed files with 83 additions and 83 deletions

View File

@ -90,12 +90,12 @@ bool Cache::Create(const CACHE_CONFIG& config,
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);
}
bool Cache::shouldUse(const SESSION* pSession)
bool Cache::should_use(const SESSION* pSession)
{
return cache_rules_should_use(m_pRules, pSession);
}

View File

@ -36,7 +36,7 @@ public:
*
* @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.
@ -45,7 +45,7 @@ public:
*
* @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.
@ -55,7 +55,7 @@ public:
*
* @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.
@ -65,13 +65,13 @@ public:
*/
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:
Cache(const std::string& name,

View File

@ -110,7 +110,7 @@ typedef struct cache_storage_api
* Get a value from the cache.
*
* @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 result Pointer to variable that after a successful return will
* point to a GWBUF.
@ -129,7 +129,7 @@ typedef struct cache_storage_api
* Put a value to the cache.
*
* @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.
* Must be one contiguous buffer.
* @return CACHE_RESULT_OK if item was successfully put,
@ -144,7 +144,7 @@ typedef struct cache_storage_api
* Delete a value from the cache.
*
* @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
* CACHE_RESULT_OK may be returned also if the entry was not present.
*/

View File

@ -67,12 +67,12 @@ CacheMT* CacheMT::Create(const std::string& name, StorageFactory* pFactory, cons
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);
bool rv = CacheSimple::mustRefresh(k, pSessionCache);
bool rv = CacheSimple::must_refresh(k, pSessionCache);
spinlock_release(&m_lockPending);
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)
{
long k = hashOfKey(key);
long k = hash_of_key(key);
spinlock_acquire(&m_lockPending);
CacheSimple::refreshed(k, pSessionCache);

View File

@ -24,7 +24,7 @@ public:
static CacheMT* Create(const std::string& name, 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);

View File

@ -95,34 +95,34 @@ CachePT* CachePT::Create(const std::string& name,
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)
{
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
@ -181,7 +181,7 @@ CachePT* CachePT::Create(const std::string& name,
return pCache;
}
Cache& CachePT::threadCache()
Cache& CachePT::thread_cache()
{
int i = thread_index();
ss_dassert(i < (int)m_caches.size());

View File

@ -25,17 +25,17 @@ public:
static CachePT* Create(const std::string& name, 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);
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:
typedef std::tr1::shared_ptr<Cache> SCache;
@ -52,7 +52,7 @@ private:
CACHE_RULES* pRules,
StorageFactory* pFactory);
Cache& threadCache();
Cache& thread_cache();
private:
CachePT(const Cache&);

View File

@ -129,39 +129,39 @@ bool CacheSimple::Create(const CACHE_CONFIG& config,
return pPending != NULL;
}
cache_result_t CacheSimple::getKey(const char* zDefaultDb,
const GWBUF* pQuery,
CACHE_KEY* pKey)
cache_result_t CacheSimple::get_key(const char* zDefaultDb,
const GWBUF* pQuery,
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,
uint32_t flags,
GWBUF** ppValue)
cache_result_t CacheSimple::get_value(const CACHE_KEY& key,
uint32_t flags,
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,
const GWBUF* pValue)
cache_result_t CacheSimple::put_value(const CACHE_KEY& key,
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
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
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);
if (!pValue)

View File

@ -23,13 +23,13 @@ class CacheSimple : public Cache
public:
~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:
CacheSimple(const std::string& name,
@ -49,9 +49,9 @@ protected:
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);

View File

@ -66,21 +66,21 @@ CacheST* CacheST::Create(const std::string& name, StorageFactory* pFactory, cons
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)
{
long k = hashOfKey(key);
long k = hash_of_key(key);
CacheSimple::refreshed(k, pSessionCache);
}
// statis
// static
CacheST* CacheST::Create(const std::string& name,
const CACHE_CONFIG* pConfig,
CACHE_RULES* pRules,

View File

@ -23,7 +23,7 @@ public:
static CacheST* Create(const std::string& name, 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);

View File

@ -138,9 +138,9 @@ int SessionCache::routeQuery(GWBUF* pPacket)
if ((session_is_autocommit(session) && !session_trx_is_active(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;
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
// 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
// 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 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)
{
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
{
@ -638,13 +638,13 @@ void SessionCache::store_result()
{
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)
{
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))
{

View File

@ -27,27 +27,27 @@ Storage::~Storage()
{
}
cache_result_t Storage::getKey(const char* zDefaultDb,
const GWBUF* pQuery,
CACHE_KEY* pKey)
cache_result_t Storage::get_key(const char* zDefaultDb,
const GWBUF* pQuery,
CACHE_KEY* pKey)
{
return m_pApi->getKey(m_pStorage, zDefaultDb, pQuery, pKey);
}
cache_result_t Storage::getValue(const CACHE_KEY& key,
uint32_t flags,
GWBUF** ppValue)
cache_result_t Storage::get_value(const CACHE_KEY& key,
uint32_t flags,
GWBUF** ppValue)
{
return m_pApi->getValue(m_pStorage, &key, flags, ppValue);
}
cache_result_t Storage::putValue(const CACHE_KEY& key,
const GWBUF* pValue)
cache_result_t Storage::put_value(const CACHE_KEY& key,
const GWBUF* 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);
}

View File

@ -22,18 +22,18 @@ class Storage
public:
~Storage();
cache_result_t getKey(const char* zDefaultDb,
cache_result_t get_key(const char* zDefaultDb,
const GWBUF* pQuery,
CACHE_KEY* pKey);
cache_result_t getValue(const CACHE_KEY& key,
cache_result_t get_value(const CACHE_KEY& key,
uint32_t flags,
GWBUF** ppValue);
cache_result_t putValue(const CACHE_KEY& key,
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:
friend class StorageFactory;