低调、勤奋。
分类: LINUX
2011-11-10 17:55:50
2. (需要root权限)在/etc/ld.so.conf 文件中添加一句:
/usr/local/lib
然后运行ldconfig命令
c 程序:
#include
#include
#include
#include
#include
int main(int argc, char *argv[])
{
if(argc!=3) {
fprintf(stderr, "Usage: %s", argv[0]);
exit(1);
}
memcached_st *memc;
memcached_return_t rc;
memcached_server_st *servers;
memc = memcached_create(NULL);
servers = memcached_server_list_append(NULL, argv[1], atoi(argv[2]),&rc);
rc = memcached_server_push(memc, servers);
char *key = "foobar";
size_t lenval, rtv;
uint32_t rtf;
obj *testobj = (obj *)malloc(sizeof(obj));
testobj->age = 10;
testobj->id = 1234;
lenval = sizeof(obj);
char test[20] = "hellp,jordan";
lenval = sizeof(test);
rc = memcached_set(memc, key, strlen(key), (char *)test, lenval, (time_t)0, (uint32_t)0);
if(rc == MEMCACHED_SUCCESS)
fprintf(stdout, "save success!\n");
else
fprintf(stdout, "save failed!\n");
free(testobj);
/*
if(rc == MEMCACHED_SUCCESS)
fprintf(stdout, "save success!\n");
else
fprintf(stdout, "save failed!\n");
free(testobj);
//printf("after get!\n");
if(rc != MEMCACHED_SUCCESS) {
fprintf(stderr, "cannot find!\n");
exit(2);
}
fprintf(stdout, "age=%d, id=%d, len=%d\n", testobj->age, testobj->id, rtv);
*/
memcached_server_free(servers);
memcached_free(memc);
}
php 访问代码:
相关文档: