Working with result sets
========================
-.. index:: object: memcached_result_st
-
-Work with memcached_result_st
-
-
--------
SYNOPSIS
--------
#include <libmemcached/memcached_pool.h>
+.. c:type:: memcached_result_st
+
.. c:function:: memcached_result_st * memcached_result_create (memcached_st *ptr, memcached_result_st *result);
.. c:function:: void memcached_result_free (memcached_result_st *result);
{
memcached_server_st *server;
- unlikely (ptr->flags.use_udp)
+ memcached_return_t unused;
+ if (not error)
+ error= &unused;
+
+ if (ptr->flags.use_udp)
{
*error= MEMCACHED_NOT_SUPPORTED;
return NULL;
}
- if (result == NULL)
- if ((result= memcached_result_create(ptr, NULL)) == NULL)
+ if (not result)
+ {
+ if (not (result= memcached_result_create(ptr, NULL)))
+ {
return NULL;
+ }
+ }
- while ((server= memcached_io_get_readable_server(ptr)) != NULL)
+ while ((server= memcached_io_get_readable_server(ptr)))
{
char buffer[MEMCACHED_DEFAULT_COMMAND_SIZE];
*error= memcached_response(server, buffer, sizeof(buffer), result);
if (*error == MEMCACHED_SUCCESS)
+ {
return result;
+ }
else if (*error == MEMCACHED_END)
+ {
memcached_server_response_reset(server);
+ }
else if (*error != MEMCACHED_NOTFOUND)
+ {
break;
+ }
}
/* We have completed reading data */
free(value);
}
+ char **keys= (char**)calloc(regression_bug_655423_COUNT, sizeof(char*));
+ size_t *key_length= (size_t *)calloc(regression_bug_655423_COUNT, sizeof(size_t));
+ for (uint32_t x= 0; x < regression_bug_655423_COUNT; x++)
+ {
+ char key[1024];
+ snprintf(key, sizeof(key), "%u", x);
+
+ keys[x]= strdup(key);
+ key_length[x]= strlen(key);
+ }
+
+ memcached_return_t rc;
+ test_compare_got(MEMCACHED_SUCCESS,
+ rc= memcached_mget(clone, (const char* const *)keys, key_length, regression_bug_655423_COUNT),
+ memcached_strerror(NULL, rc));
+
+ uint32_t count= 0;
+ memcached_result_st *result= NULL;
+ while ((result= memcached_fetch_result(clone, result, NULL)))
+ {
+ test_compare(100, memcached_result_length(result));
+ count++;
+ }
+
+ test_true(count > 100); // If we don't get back atleast this, something is up
+
+ /* Release all allocated resources */
+ for (size_t x= 0; x < regression_bug_655423_COUNT; ++x)
+ {
+ free(keys[x]);
+ }
+ free(keys);
+ free(key_length);
+
+
memcached_free(clone);
return TEST_SUCCESS;