Ejemplo n.º 1
0
int32_t CVDCMemcache::MemcacheIfKeyExist(memcached_st* memc, const char* szKey, const size_t keyLen)
{
	DB_MUTEX_GUARD(cf_mutex, m_dbcrit);
	memcached_return rc;
	rc = memcached_exist(memc, szKey, keyLen);
	if(rc != MEMCACHED_SUCCESS)
	{
		WRITE_WARNING_LOG( "warning: key is not exist in memcache! errorcode=%d\n", rc);
		return E_MEMCACHE_KEY_NOTFOUND;
	}
	//WRITE_DEBUG_LOG( "the key is exist in memcache! key=%s, keylen=%d\n", szKey, keyLen);

	return S_OK;
}
bool Memcached::CheckExist(std::string& sKey)
{
	if (m_pMemc == NULL)
	{
		return false;
	}

	m_rc = memcached_exist(m_pMemc, sKey.c_str(), sKey.length());
	if (m_rc != MEMCACHED_SUCCESS)
	{
		m_sErrMsg = "memchaced_exist failed.";
		return false;
	}

	return true;
}
Ejemplo n.º 3
0
ESPCacheResult ESPMemCached::exists(const char* groupID, const char* cacheID)
{
#if (LIBMEMCACHED_VERSION_HEX<0x53000)
    throw makeStringException(0, "memcached_exist not supported in this version of libmemcached");
#endif

    memcached_return_t rc;
    size_t groupIDLength = strlen(groupID);
    if (groupIDLength)
        rc = memcached_exist_by_key(connection, groupID, groupIDLength, cacheID, strlen(cacheID));
    else
        rc = memcached_exist(connection, cacheID, strlen(cacheID));

    if (rc != MEMCACHED_NOTFOUND)
        assertOnError(rc, "'Exists' request failed - ");
    return rc == MEMCACHED_NOTFOUND ? ESPCacheNotFound : (rc == MEMCACHED_SUCCESS ? ESPCacheSuccess : ESPCacheError);
}
Ejemplo n.º 4
0
int memcached_key_exist(char *key, size_t key_len)
{
	if (memcached_exist(memc, key, key_len) == MEMCACHED_SUCCESS)
		return 0;
	return -1;
}