size_t key_length= 0;
char *value= memcached_fetch(&memc, ret_key, &key_length,
&value_length, flags, rc);
- if (value)
+ if (value && ret_val.empty())
{
ret_val.reserve(value_length);
memcpy(&*ret_val.begin(), value, value_length);
memcached_return rc;
size_t value_length= 0;
+ if (key.empty())
+ {
+ return false;
+ }
char *value= memcached_get(&memc, key.c_str(), key.length(),
&value_length, &flags, &rc);
- if (value != NULL)
+ if (value != NULL && ret_val.empty())
{
ret_val.reserve(value_length);
memcpy(&ret_val[0], value, value_length);
memcached_return rc;
size_t value_length= 0;
+ if (master_key.empty() || key.empty())
+ {
+ return false;
+ }
char *value= memcached_get_by_key(&memc,
master_key.c_str(), master_key.length(),
key.c_str(), key.length(),
* If the std::vector of keys is empty then we cannot
* call memcached_mget as we will get undefined behavior.
*/
- if (!real_keys.empty())
+ if (! real_keys.empty())
{
memcached_return rc= memcached_mget(&memc, &real_keys[0], &key_len[0],
real_keys.size());
time_t expiration,
uint32_t flags)
{
+ if (key.empty() || value.empty())
+ {
+ return false;
+ }
memcached_return rc= memcached_set(&memc,
key.c_str(), key.length(),
&value[0], value.size(),
time_t expiration,
uint32_t flags)
{
+ if (master_key.empty() ||
+ key.empty() ||
+ value.empty())
+ {
+ return false;
+ }
memcached_return rc= memcached_set_by_key(&memc, master_key.c_str(),
master_key.length(),
key.c_str(), key.length(),
bool increment(const std::string &key, unsigned int offset, uint64_t *value)
{
+ if (key.empty())
+ {
+ return false;
+ }
memcached_return rc= memcached_increment(&memc, key.c_str(), key.length(),
offset, value);
return (rc == MEMCACHED_SUCCESS);
bool decrement(const std::string &key, unsigned int offset, uint64_t *value)
{
+ if (key.empty())
+ {
+ return false;
+ }
memcached_return rc= memcached_decrement(&memc, key.c_str(),
key.length(),
offset, value);
bool add(const std::string &key, const std::vector<char> &value)
{
+ if (key.empty() || value.empty())
+ {
+ return false;
+ }
memcached_return rc= memcached_add(&memc, key.c_str(), key.length(),
&value[0], value.size(), 0, 0);
return (rc == MEMCACHED_SUCCESS);
const std::string &key,
const std::vector<char> &value)
{
+ if (master_key.empty() ||
+ key.empty() ||
+ value.empty())
+ {
+ return false;
+ }
memcached_return rc= memcached_add_by_key(&memc,
master_key.c_str(),
master_key.length(),
bool replace(const std::string &key, const std::vector<char> &value)
{
+ if (key.empty() ||
+ value.empty())
+ {
+ return false;
+ }
memcached_return rc= memcached_replace(&memc, key.c_str(), key.length(),
&value[0], value.size(),
0, 0);
const std::string &key,
const std::vector<char> &value)
{
+ if (master_key.empty() ||
+ key.empty() ||
+ value.empty())
+ {
+ return false;
+ }
memcached_return rc= memcached_replace_by_key(&memc,
master_key.c_str(),
master_key.length(),
bool prepend(const std::string &key, const std::vector<char> &value)
{
+ if (key.empty() || value.empty())
+ {
+ return false;
+ }
memcached_return rc= memcached_prepend(&memc, key.c_str(), key.length(),
&value[0], value.size(), 0, 0);
return (rc == MEMCACHED_SUCCESS);
const std::string &key,
const std::vector<char> &value)
{
+ if (master_key.empty() ||
+ key.empty() ||
+ value.empty())
+ {
+ return false;
+ }
memcached_return rc= memcached_prepend_by_key(&memc,
master_key.c_str(),
master_key.length(),
bool append(const std::string &key, const std::vector<char> &value)
{
+ if (key.empty() || value.empty())
+ {
+ return false;
+ }
memcached_return rc= memcached_append(&memc,
key.c_str(),
key.length(),
const std::string &key,
const std::vector<char> &value)
{
+ if (master_key.empty() ||
+ key.empty() ||
+ value.empty())
+ {
+ return false;
+ }
memcached_return rc= memcached_append_by_key(&memc,
master_key.c_str(),
master_key.length(),
const std::vector<char> &value,
uint64_t cas_arg)
{
+ if (key.empty() || value.empty())
+ {
+ return false;
+ }
memcached_return rc= memcached_cas(&memc, key.c_str(), key.length(),
&value[0], value.size(),
0, 0, cas_arg);
const std::vector<char> &value,
uint64_t cas_arg)
{
+ if (master_key.empty() ||
+ key.empty() ||
+ value.empty())
+ {
+ return false;
+ }
memcached_return rc= memcached_cas_by_key(&memc,
master_key.c_str(),
master_key.length(),
bool remove(const std::string &key)
{
+ if (key.empty())
+ {
+ return false;
+ }
memcached_return rc= memcached_delete(&memc, key.c_str(), key.length(), 0);
return (rc == MEMCACHED_SUCCESS);
}
bool removeByKey(const std::string &master_key,
const std::string &key)
{
+ if (master_key.empty() || key.empty())
+ {
+ return false;
+ }
memcached_return rc= memcached_delete_by_key(&memc,
master_key.c_str(),
master_key.length(),