memcached_return *error);
memcached_return
- memcached_mget (memcached_st *ptr,
- char **keys, size_t *key_length,
- unsigned int number_of_keys);
+ memcached_mget (memcached_st *ptr,
+ char **keys, size_t *key_length,
+ unsigned int number_of_keys);
char *memcached_fetch (memcached_st *ptr,
char *key, size_t *key_length,
memcached_mget() is used to select multiple keys at once. For multiple key
operations it is always faster to use this function. This function always
works asynchronously. memcached_fetch() is then used to retrieve any keys
-found. No error is given on keys that are not found.
+found. No error is given on keys that are not found. You must call either
+memcached_fetch() or memcached_fetch_result() after a successful call to
+memcached_mget(). You should continue to call these functions until they
+return NULL (aka no more values). If you need to quit in the middle of a
+memcached_get() call, execute a memcached_quit(). After you do this, you can
+issue new queries against the server.
memcached_fetch() is used to fetch an individual value from the server.
memcached_mget() must always be called before using this method. You
return 0;
}
+#define VALUE_SIZE_BUG5 1048064
+uint8_t user_supplied_bug5(memcached_st *memc)
+{
+ memcached_return rc;
+ char *keys[]= {"036790384900", "036790384902", "036790384904", "036790384906"};
+ size_t key_length[]= {strlen("036790384900"), strlen("036790384902"), strlen("036790384904"), strlen("036790384906")};
+ char return_key[MEMCACHED_MAX_KEY];
+ size_t return_key_length;
+ char *value;
+ size_t value_length;
+ uint16_t flags;
+ unsigned int count;
+ unsigned int x;
+ char insert_data[VALUE_SIZE_BUG5];
+
+ for (x= 0; x < VALUE_SIZE_BUG5; x++)
+ insert_data[x]= rand();
+
+ memcached_flush(memc, 0);
+ value= memcached_get(memc, keys[0], key_length[0],
+ &value_length, &flags, &rc);
+ assert(value == NULL);
+ rc= memcached_mget(memc, keys, key_length, 4);
+
+ count= 0;
+ while ((value= memcached_fetch(memc, return_key, &return_key_length,
+ &value_length, &flags, &rc)))
+ count++;
+ assert(count == 0);
+
+ for (x= 0; x < 4; x++)
+ {
+ rc= memcached_set(memc, keys[x], key_length[x],
+ insert_data, VALUE_SIZE_BUG5,
+ (time_t)0, (uint16_t)0);
+ assert(rc == MEMCACHED_SUCCESS);
+ }
+
+ for (x= 0; x < 10; x++)
+ {
+ value= memcached_get(memc, keys[0], key_length[0],
+ &value_length, &flags, &rc);
+ assert(value);
+ free(value);
+
+ rc= memcached_mget(memc, keys, key_length, 4);
+ count= 0;
+ while ((value= memcached_fetch(memc, return_key, &return_key_length,
+ &value_length, &flags, &rc)))
+ {
+ count++;
+ free(value);
+ }
+ assert(count == 4);
+ }
+
+ return 0;
+}
+
uint8_t result_static(memcached_st *memc)
{
memcached_result_st result;
{"user_supplied_bug2", 0, user_supplied_bug2 },
{"user_supplied_bug3", 0, user_supplied_bug3 },
{"user_supplied_bug4", 0, user_supplied_bug4 },
+ {"user_supplied_bug5", 1, user_supplied_bug5 },
{0, 0, 0}
};