Any suggestions --- new to memcache

sivaramakrishna sista srksista at
Mon Apr 30 12:33:05 UTC 2007


I am a new user to memcache. I have written a sample code in C. But I am get the expected values.

The below the sample code, please correct if any thing is wrong:

#include <err.h>
#include <sysexits.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>

#include <memcache.h>

struct empInfo
 char name[20];
 int empid;
 int salary;

int main()
struct memcache *mc = NULL;
        struct memcache_req *req;
        struct memcache_res *res;
        u_int32_t i;
        void *val;

    struct empInfo emp = {"abc", 1,1200};
        mc = mc_new();
        if (mc == NULL)
                printf("Unable to allocate a new memcache object \n");

        mc_server_add(mc, "", "11211");

     mc_set(mc,, strlen(, &emp, MCM_CSTRLEN(emp), 0, 0);

     val = mc_aget(mc, "abc",MCM_CSTRLEN("abc"));
        printf(" val is %s \n", (char *) val);
        if (val != NULL) {
                printf(" val is %s \n", (char *) val);
return 0;

mc_get is not returning the correct name which I stored using mc_set.

Can anyone give me some suggestions.


Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 

More information about the memcached mailing list