#include #include #include #include const int PORT = 11211; const int TIMEOUT = 60; int main() { memcached_st memc; memcached_create( &memc );//init structure memcached_server_add(&memc, "localhost", PORT); const char* key = "mykey"; srand(time(0)); char value[256]; sprintf(value,"This is the cached value %i", rand() ); memcached_set(&memc, key, strlen(key), value, strlen(value)+1, TIMEOUT, 0); //the +1 is just to include trailing \0 printf("wrote: %s\n", value); unsigned int size; unsigned int flags; memcached_return errors; char* returned = memcached_get(&memc, key, strlen(key), &size, &flags, &errors); printf("Returned: %s\n", returned); return 0; }