char buffer[MEMCACHED_DEFAULT_COMMAND_SIZE];
unsigned int server_key;
char *value;
+ memcached_return rc;
LIBMEMCACHED_MEMCACHED_GET_START();
*value_length= 0;
value= memcached_value_fetch(ptr, key, &key_length, value_length, flags,
error, 0, server_key);
+ /* We need to read END */
+ rc= memcached_response(ptr, buffer, MEMCACHED_DEFAULT_COMMAND_SIZE, server_key);
+ if (rc != MEMCACHED_NOTFOUND)
+ {
+ free(value);
+ *value_length= 0;
+ *error= MEMCACHED_PROTOCOL_ERROR;
+ }
LIBMEMCACHED_MEMCACHED_GET_END();
return value;
(unsigned int)pairs[x].key_length, pairs[x].key);
}
+ for (x= 0; x < opt_default_pairs; x++)
+ {
+ printf("Key(%u) %.10s \n", x, pairs[x].key);
+ char *value;
+ size_t value_length;
+ uint16_t flags;
+
+ value= memcached_get(memc, pairs[x].key, pairs[x].key_length,
+ &value_length,
+ &flags, &rc);
+
+ WATCHPOINT_ERROR(rc);
+ if (rc != MEMCACHED_SUCCESS)
+ fprintf(stderr, "Failured on read of %.*s\n",
+ (unsigned int)pairs[x].key_length, pairs[x].key);
+ printf("\t%.10s\n", value);
+ free(value);
+ }
+
pairs_free(pairs);
free(opt_servers);
memcached_deinit(memc);
}
+void get_test4(void)
+{
+ memcached_st *memc;
+ memcached_return rc;
+ char *key= "foo";
+ char *value;
+ size_t value_length= 8191;
+ char *string;
+ size_t string_length;
+ uint16_t flags;
+ int x;
+
+ value = (char*)malloc(value_length);
+ assert(value);
+
+ for (x= 0; x < value_length; x++)
+ value[x] = (char) (x % 127);
+
+ memc= memcached_init(NULL);
+ assert(memc);
+ rc= memcached_server_add(memc, "localhost", 0);
+ assert(rc == MEMCACHED_SUCCESS);
+
+ rc= memcached_set(memc, key, strlen(key),
+ value, value_length,
+ (time_t)0, (uint16_t)0);
+ assert(rc == MEMCACHED_SUCCESS);
+
+ for (x= 0; x < 10; x++)
+ {
+ string= memcached_get(memc, key, strlen(key),
+ &string_length, &flags, &rc);
+
+ assert(rc == MEMCACHED_SUCCESS);
+ assert(string);
+ assert(string_length == value_length);
+ assert(!memcmp(string, value, string_length));
+ free(string);
+ }
+
+ free(value);
+
+ memcached_deinit(memc);
+}
+
void stats_servername_test(void)
{
memcached_return rc;
assert(rc == MEMCACHED_SUCCESS);
x= 0;
- while (return_value= memcached_fetch(memc, return_key, &return_key_length,
- &return_value_length, &flags, &rc))
+ while ((return_value= memcached_fetch(memc, return_key, &return_key_length,
+ &return_value_length, &flags, &rc)))
{
assert(return_value);
assert(rc == MEMCACHED_SUCCESS);
}
-int main(int argc, char argvp[])
+int main(int argc, char *argv[])
{
/* Clean the server before beginning testing */
flush_test();
+#ifdef CRAP
init_test();
allocation_test();
connection_test();
get_test();
get_test2();
get_test3();
+#endif
+ get_test4();
stats_servername_test();
increment_test();