From 14770e392f07678217a09392cce920da9b4e5ca4 Mon Sep 17 00:00:00 2001 From: Padraig O'Sullivan Date: Sun, 26 Jul 2009 19:54:50 -0400 Subject: [PATCH] Updated the fetch method in the C++ interface and added doxygen comments to it. --- libmemcached/memcached.hpp | 15 +++++++++++---- tests/plus.cpp | 8 ++------ 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/libmemcached/memcached.hpp b/libmemcached/memcached.hpp index ecb474aa..55941f10 100644 --- a/libmemcached/memcached.hpp +++ b/libmemcached/memcached.hpp @@ -91,16 +91,23 @@ public: return memcached_strerror(NULL, rc); } + /** + * Fetches an individual value from the server. + * + * @param[in] key key of object to fetch + * @param[out] ret_val store returned object in this vector + * @return true on success; false on failure + */ bool fetch(std::string &key, - std::vector &ret_val, - uint32_t *flags, - memcached_return *rc) + std::vector &ret_val) { char ret_key[MEMCACHED_MAX_KEY]; size_t value_length= 0; size_t key_length= 0; + memcached_return rc; + uint32_t flags= 0; char *value= memcached_fetch(&memc, ret_key, &key_length, - &value_length, flags, rc); + &value_length, &flags, &rc); if (value && ret_val.empty()) { ret_val.reserve(value_length); diff --git a/tests/plus.cpp b/tests/plus.cpp index 3431fd18..78e4670f 100644 --- a/tests/plus.cpp +++ b/tests/plus.cpp @@ -212,7 +212,6 @@ test_return mget_test(memcached_st *memc) values.push_back(&val1); values.push_back(&val2); values.push_back(&val3); - uint32_t flags; string return_key; vector return_value; @@ -224,8 +223,7 @@ test_return mget_test(memcached_st *memc) rc= mc.mget(keys); assert(rc == true); - while (mc.fetch(return_key, return_value, - &flags, &mc_rc)) + while (mc.fetch(return_key, return_value)) { assert(return_value.size() != 0); return_value.clear(); @@ -238,10 +236,8 @@ test_return mget_test(memcached_st *memc) rc= mc.mget(keys); assert(rc == true); - while ((mc.fetch(return_key, return_value, - &flags, &mc_rc))) + while ((mc.fetch(return_key, return_value))) { - assert(mc_rc == MEMCACHED_SUCCESS); assert(return_key.length() == return_value.size()); assert(!memcmp(&return_value[0], return_key.c_str(), return_value.size())); } -- 2.30.2