Work on C++ library. Pulled out result methods - need to define 'result'
author <patg@patg.net> <>
Mon, 5 May 2008 02:27:29 +0000 (22:27 -0400)
committer <patg@patg.net> <>
Mon, 5 May 2008 02:27:29 +0000 (22:27 -0400)
class.

include/memcached.hh
tests/plus.cpp

index d394bbda549f4bcd161e1a4e3706d50bd7ae66bc..05583c74a943450f192c4027075e6df4713fad03 100644 (file)
@@ -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);
 
index 10b2440a7c2f2ea02c5d7b86271500ff8e81cbe5..2fb0e83da94a896157bfade6ec76a6b8a63891df 100644 (file)
@@ -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}
 };