From 0acd9f0be5dbd76e5cd22cf1c3f8cf7d9fc972e4 Mon Sep 17 00:00:00 2001 From: mike tsai Date: Thu, 19 Nov 2009 14:46:49 -0800 Subject: [PATCH] Added get/set behavior functions to the C++ interface. Added a test to exercise the new change --- libmemcached/memcached.hpp | 11 +++++++++++ tests/plus.cpp | 15 +++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/libmemcached/memcached.hpp b/libmemcached/memcached.hpp index d7086b4c..107b01c5 100644 --- a/libmemcached/memcached.hpp +++ b/libmemcached/memcached.hpp @@ -143,6 +143,17 @@ public: return memcached_strerror(NULL, rc); } + + bool setBehavior(memcached_behavior flag, uint64_t data) { + memcached_return rc; + rc= memcached_behavior_set(&memc, flag, data); + return (rc == MEMCACHED_SUCCESS); + } + + uint64_t getBehavior(memcached_behavior flag) { + return memcached_behavior_get(&memc, flag); + } + /** * Return the string which contains the list of memcached servers being * used. diff --git a/tests/plus.cpp b/tests/plus.cpp index d988334f..6ffd090f 100644 --- a/tests/plus.cpp +++ b/tests/plus.cpp @@ -27,6 +27,7 @@ extern "C" { test_return_t increment_test(memcached_st *memc); test_return_t basic_master_key_test(memcached_st *memc); test_return_t mget_result_function(memcached_st *memc); + test_return_t basic_behavior(memcached_st *memc); test_return_t mget_test(memcached_st *memc); memcached_return callback_counter(memcached_st *, memcached_result_st *, @@ -259,12 +260,26 @@ test_return_t mget_test(memcached_st *memc) return TEST_SUCCESS; } +test_return_t basic_behavior(memcached_st *memc) +{ + Memcache mc(memc); + bool rc; + uint64_t value = 1; + rc = mc.setBehavior(MEMCACHED_BEHAVIOR_VERIFY_KEY, value); + assert(rc); + uint64_t behavior = mc.getBehavior(MEMCACHED_BEHAVIOR_VERIFY_KEY); + assert(behavior == value); + + return TEST_SUCCESS; +} + test_st tests[] ={ { "basic", 0, basic_test }, { "basic_master_key", 0, basic_master_key_test }, { "increment_test", 0, increment_test }, { "mget", 1, mget_test }, { "mget_result_function", 1, mget_result_function }, + { "basic_behavior", 0, basic_behavior }, {0, 0, 0} }; -- 2.30.2