From 3b967603f05c738a63c8f72c4ac49a1f79eb0091 Mon Sep 17 00:00:00 2001 From: Date: Sun, 4 May 2008 22:27:29 -0400 Subject: [PATCH] Work on C++ library. Pulled out result methods - need to define 'result' class. --- include/memcached.hh | 22 ++-------------------- tests/plus.cpp | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 20 deletions(-) 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} }; -- 2.30.2