surbhi
surbhi

Reputation: 41

memcache_get() giving segmentation fault

I have a following simple memcache code:::::

memcached_return *rc = NULL;

char *sur = "SURBHI";

memcached_set(cacheClient, "SB", strlen("SB"), sur, strlen(sur), (time_t)0, (uint32_t)0);

char *value1;

memcached_get(cacheClient, "SB", strlen("SB"), 6, (uint32_t)0, rc);

The call to memcache_get gives segmentation fault. Debugger gave following:

0 0x00007ffff79c434c in memcached_get_by_key () from /usr/lib/libmemcached.so.5

1 0x00007ffff79c454f in memcached_get () from /usr/lib/libmemcached.so.5

Did anyone faced similar issue, or has any idea about the solution?

Upvotes: 0

Views: 987

Answers (1)

Filip Kwiatkowski
Filip Kwiatkowski

Reputation: 665

The last three parameters of memcached_get should be the pointers through which you will get informations like value, length and error code. See below:

char *key = "key";
size_t value_length;
memcached_return_t ret;
uint32_t flags;
char *value = memcached_get(memc, key, strlen(key), &value_length, &flags, &ret);

if (ret == MEMCACHED_SUCCESS) {
  // ok
} else {
  // error
}

Upvotes: 1

Related Questions