From: Date: Mon, 5 May 2008 02:27:29 +0000 (-0400) Subject: Work on C++ library. Pulled out result methods - need to define 'result' X-Git-Tag: _20~3 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=3b967603f05c738a63c8f72c4ac49a1f79eb0091;p=m6w6%2Flibmemcached Work on C++ library. Pulled out result methods - need to define 'result' class. --- diff --git a/include/memcached.hh b/include/memcached.hh index d394bbda..05583c74 100644 --- a/include/memcached.hh +++ b/include/memcached.hh @@ -24,24 +24,6 @@ public: memcached_clone(&memc, clone); WATCHPOINT; } - memcached_result_st *fetch_result() - { - memcached_return rc; - return memcached_fetch_result(&memc, &result, &rc); - } - /* - - memcached_return fetch_execute( - memcached_return ((*callback[]))(&memc, - &result, - void *context, - unsigned in number_of_callbacks)) - { - return memcached_fetch_execute(&memc, - (*callback[])(&memc, &result, context, - number_of_callbacks)); - } - */ char *fetch (char *key, size_t *key_length, size_t *value_length) { uint32_t flags; @@ -185,8 +167,8 @@ public: (uint32_t)0, cas); } - // Ok, so how do I have a 'delete' method, delete being a keyword? - memcached_return delete(char *key) + // using 'remove' vs. 'delete' since 'delete' is a keyword + memcached_return remove(char *key) { return memcached_delete (&memc, key, strlen(key), (time_t)0); diff --git a/tests/plus.cpp b/tests/plus.cpp index 10b2440a..2fb0e83d 100644 --- a/tests/plus.cpp +++ b/tests/plus.cpp @@ -29,6 +29,39 @@ uint8_t basic_test(memcached_st *memc) return 0; } +uint8_t increment_test(memcached_st *memc) +{ + Memcached mcach; + memcached_return rc; + char *key= "inctest"; + char *inc_value= "1"; + char *ret_value; + uint64_t int_inc_value; + uint64_t int_ret_value; + size_t value_length; + + mcach.set(key, inc_value, strlen(inc_value)); + ret_value= mcach.get(key, &value_length); + printf("\nretvalue %s\n",ret_value); + int_inc_value= atoi(inc_value); + int_ret_value= atoi(ret_value); + assert(int_ret_value == int_inc_value); + + rc= mcach.increment(key, 1, &int_ret_value); + assert(rc == MEMCACHED_SUCCESS); + assert(int_ret_value == 2); + + rc= mcach.increment(key, 1, &int_ret_value); + assert(rc == MEMCACHED_SUCCESS); + assert(int_ret_value == 3); + + rc= mcach.increment(key, 5, &int_ret_value); + assert(rc == MEMCACHED_SUCCESS); + assert(int_ret_value == 8); + + return 0; +} + uint8_t basic_master_key_test(memcached_st *memc) { Memcached foo; @@ -53,6 +86,7 @@ uint8_t basic_master_key_test(memcached_st *memc) test_st tests[] ={ {"basic", 0, basic_test }, + {"basic", 0, increment_test }, {"basic_master_key", 0, basic_master_key_test }, {0, 0, 0} };