On Friday, April 12, 2013 1:51:33 PM UTC+5:30, unag...@gmail.com wrote: > > When I run following program from commandline on CentOS 6.4, I get the > expected results but when I run it as Apache cgi, I error Couldn't store > key: SYSTEM ERROR error. I am running Memcached, Apache and program > through the same user. > > What could I be doing wrong ? > > #include<stdio.h> > #include<string.h> > #include <libmemcached/memcached.h> > > int main(int argc, char **argv) { > memcached_server_st *servers = NULL; > memcached_st *memc; > memcached_return rc; > > char *key= "keystring"; > char *value= "keyvalue"; > char *key1= "keystring1"; > char *value1= "keyvalue1"; > > memc= memcached_create(NULL); > servers= memcached_server_list_append(servers, "localhost", 11211, &rc); > rc= memcached_server_push(memc, servers); > > printf("Content-Type: text/plain;charset=us-ascii\n\n"); > > if (rc == MEMCACHED_SUCCESS) > printf("Added server successfully 1\n"); > else > printf("Couldn't add server: %s\n",memcached_strerror(memc, > rc)); > > memcached_server_free(servers); > > rc= memcached_set(memc, key, strlen(key), value, strlen(value), > (time_t)0, (uint32_t)0); > > if (rc == MEMCACHED_SUCCESS) > printf("Key stored successfully\n"); > else > printf("Couldn't store key: %s\n",memcached_strerror(memc, rc)); > > char *keys[]= {"keystring", "keystring1"}; > size_t key_length[]= {9, 10}; > unsigned int x; > uint32_t flags; > > char return_key[MEMCACHED_MAX_KEY]; > size_t return_key_length; > char *return_value; > size_t return_value_length; > > // Single Get > value= memcached_get(memc, "keystring", strlen("keystring"), > &return_value_length, &flags, &rc); > if (rc != MEMCACHED_SUCCESS) { > printf("Single get error: %s\n", memcached_strerror(memc, rc)); > /* memcached_free(memc); > return -2;*/ > } > > > // Multi Get > rc= memcached_mget(memc, keys, key_length, 2); > printf("---------- 1 -------------\n"); > x= 0; > > if (rc == MEMCACHED_SUCCESS) > { > printf("---------- 2 -------------\n"); > > while ((return_value= memcached_fetch(memc, return_key, > &return_key_length, > > &return_value_length, &flags, &rc))) > { > printf("---------- 3 -------------\n"); > > if (rc == MEMCACHED_SUCCESS) > { > printf("---------- 4 -------------\n"); > printf("Key %s returned %s\n",return_key, > return_value); > } > } > } > else > { > printf("Multi get error: %s\n", memcached_strerror(memc, rc)); > memcached_free(memc); > return -2; > } > > > memcached_free(memc); > return 0; > } > >
-- --- You received this message because you are subscribed to the Google Groups "memcached" group. To unsubscribe from this group and stop receiving emails from it, send an email to memcached+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.