Any suggestions --- new to memcache

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


HI,

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, "192.168.30.6", "11211");

     mc_set(mc, emp.name, strlen(emp.name)-1, &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);
                free(val);
        }
 mc_free(mc);
return 0;
}

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


Can anyone give me some suggestions.

Thanks
Siva



__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 


More information about the memcached mailing list