From: Trond Norbye Date: Wed, 14 Oct 2009 18:50:03 +0000 (+0200) Subject: Refactor: memcached_mget_execute -> memcached_mget_execute_by_key X-Git-Tag: 0.35~11^2 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=ad3f0539710d724e2d343b19abca6ce2ec0c7c9e;p=m6w6%2Flibmemcached Refactor: memcached_mget_execute -> memcached_mget_execute_by_key --- diff --git a/docs/Makefile.am b/docs/Makefile.am index ec551276..9a4ee49a 100644 --- a/docs/Makefile.am +++ b/docs/Makefile.am @@ -75,6 +75,7 @@ man_MANS = libmemcached.3\ memcached_mget.3\ memcached_mget_by_key.3\ memcached_mget_execute.3 \ + memcached_mget_execute_by_key.3 \ memcached_prepend.3\ memcached_prepend_by_key.3\ memcached_replace.3\ @@ -216,6 +217,9 @@ memcached_mget_by_key.3: memcached_get.pod memcached_mget_execute.3: memcached_get.pod ${POD2MAN} -c "libmemcached" -r "" -s 3 ${top_srcdir}/docs/memcached_get.pod > memcached_mget_execute.3 +memcached_mget_execute_by_key.3: memcached_get.pod + ${POD2MAN} -c "libmemcached" -r "" -s 3 ${top_srcdir}/docs/memcached_get.pod > memcached_mget_execute_by_key.3 + memcached_fetch.3: memcached_get.pod ${POD2MAN} -c "libmemcached" -r "" -s 3 ${top_srcdir}/docs/memcached_get.pod > memcached_fetch.3 diff --git a/docs/memcached_get.pod b/docs/memcached_get.pod index 5dde1edc..db2c9b5a 100644 --- a/docs/memcached_get.pod +++ b/docs/memcached_get.pod @@ -1,6 +1,7 @@ =head1 NAME -memcached_get, memcached_mget, memcached_fetch - Get a value +memcached_get, memcached_mget, memcached_fetch, memcached_mget_execute, +memcached_mget_execute_by_key - Get a value =head1 LIBRARY @@ -54,10 +55,8 @@ C Client Library for memcached (libmemcached, -lmemcached) unsigned int number_of_callbacks); - memcached_return + memcached_return memcached_mget_execute(memcached_st *ptr, - const char *master_key, - size_t master_key_length, const char * const *keys, const size_t *key_length, size_t number_of_keys, @@ -65,6 +64,17 @@ C Client Library for memcached (libmemcached, -lmemcached) void *context, unsigned int number_of_callbacks); + memcached_return + memcached_mget_execute_by_key(memcached_st *ptr, + const char *master_key, + size_t master_key_length, + const char * const *keys, + const size_t *key_length, + size_t number_of_keys, + memcached_execute_function *callback, + void *context, + unsigned int number_of_callbacks); + =head1 DESCRIPTION @@ -115,14 +125,15 @@ you supply the calling function. Currently only one value is being passed to each function call. In the future there will be an option to allow this to be an array. -memcached_mget_execute() is similar to memcached_mget(), but it may trigger -the supplied callbacks with result sets while sending out the queries. If -you try to perform a really large multiget with memcached_mget() you may -encounter a deadlock in the OS kernel (we fail to write data to the socket -because the input buffer is full). memcached_mget_execute() solves this -problem by processing some of the results before continuing sending out -requests. Please note that this function is only available in the binary -protocol. +memcached_mget_execute() and memcached_mget_execute_by_key() is +similar to memcached_mget(), but it may trigger the supplied callbacks +with result sets while sending out the queries. If you try to perform +a really large multiget with memcached_mget() you may encounter a +deadlock in the OS kernel (we fail to write data to the socket because +the input buffer is full). memcached_mget_execute() solves this +problem by processing some of the results before continuing sending +out requests. Please note that this function is only available in the +binary protocol. memcached_get_by_key() and memcached_mget_by_key() behave in a similar nature as memcached_get() and memcached_mget(). The difference is that they take diff --git a/libmemcached/memcached_get.c b/libmemcached/memcached_get.c index cf0d210d..3436186f 100644 --- a/libmemcached/memcached_get.c +++ b/libmemcached/memcached_get.c @@ -279,14 +279,27 @@ memcached_return memcached_mget_by_key(memcached_st *ptr, } memcached_return memcached_mget_execute(memcached_st *ptr, - const char *master_key, - size_t master_key_length, const char * const *keys, const size_t *key_length, size_t number_of_keys, memcached_execute_function *callback, void *context, unsigned int number_of_callbacks) +{ + return memcached_mget_execute_by_key(ptr, NULL, 0, keys, key_length, + number_of_keys, callback, + context, number_of_callbacks); +} + +memcached_return memcached_mget_execute_by_key(memcached_st *ptr, + const char *master_key, + size_t master_key_length, + const char * const *keys, + const size_t *key_length, + size_t number_of_keys, + memcached_execute_function *callback, + void *context, + unsigned int number_of_callbacks) { if ((ptr->flags & MEM_BINARY_PROTOCOL) == 0) return MEMCACHED_NOT_SUPPORTED; diff --git a/libmemcached/memcached_get.h b/libmemcached/memcached_get.h index 11dd7fee..bf3aeb53 100644 --- a/libmemcached/memcached_get.h +++ b/libmemcached/memcached_get.h @@ -56,8 +56,6 @@ memcached_result_st *memcached_fetch_result(memcached_st *ptr, LIBMEMCACHED_API memcached_return memcached_mget_execute(memcached_st *ptr, - const char *master_key, - size_t master_key_length, const char * const *keys, const size_t *key_length, size_t number_of_keys, @@ -65,6 +63,17 @@ memcached_return memcached_mget_execute(memcached_st *ptr, void *context, unsigned int number_of_callbacks); +LIBMEMCACHED_API +memcached_return memcached_mget_execute_by_key(memcached_st *ptr, + const char *master_key, + size_t master_key_length, + const char * const *keys, + const size_t *key_length, + size_t number_of_keys, + memcached_execute_function *callback, + void *context, + unsigned int number_of_callbacks); + #ifdef __cplusplus } #endif diff --git a/tests/function.c b/tests/function.c index c53ac700..2bc0192b 100644 --- a/tests/function.c +++ b/tests/function.c @@ -1484,8 +1484,7 @@ static test_return_t mget_execute(memcached_st *memc) /* Try to get all of them with a large multiget */ unsigned int counter= 0; memcached_execute_function callbacks[1]= { [0]= &callback_counter }; - rc= memcached_mget_execute(memc, NULL, 0, - (const char**)keys, key_length, + rc= memcached_mget_execute(memc, (const char**)keys, key_length, (size_t)max_keys, callbacks, &counter, 1); if (binary)