return rc;
}
- if (memcached_failed(rc= memcached_validate_key_length(key_length, ptr->flags.binary_protocol)))
- {
- return rc;
- }
-
if (memcached_failed(rc= memcached_key_test(*ptr, (const char **)&key, &key_length, 1)))
{
return memcached_set_error(*ptr, rc, MEMCACHED_AT);
return rc;
}
- rc= memcached_validate_key_length(key_length, ptr->flags.binary_protocol);
- if (memcached_failed(rc))
+ if (memcached_failed(rc= memcached_key_test(*ptr, (const char **)&key, &key_length, 1)))
{
- return rc;
+ return memcached_set_error(*ptr, rc, MEMCACHED_AT);
}
if (expiration)
memcached_server_write_instance_st instance;
instance= memcached_server_instance_fetch(ptr, server_key);
- /* 256 I BELIEVE is the upper limit of slabs */
- for (uint32_t x= 0; x < 256; x++)
+ /* MAX_NUMBER_OF_SLAB_CLASSESdefined to 200 in Memcached 1.4.10 */
+ for (uint32_t x= 0; x < 200; x++)
{
char buffer[MEMCACHED_DEFAULT_COMMAND_SIZE];
int buffer_length= snprintf(buffer, sizeof(buffer), "%u", x);
No support for Binary protocol yet
@todo Fix this so that we just flush, switch to ascii, and then go back to binary.
*/
- if (ptr->flags.binary_protocol)
+ if (memcached_is_binary(ptr))
{
- return MEMCACHED_FAILURE;
+ return memcached_set_error(*ptr, MEMCACHED_NOT_SUPPORTED, MEMCACHED_AT, memcached_literal_param("Binary protocol is not supported for memcached_dump()"));
}
return ascii_dump(ptr, callback, context, number_of_callbacks);
if (memcached_is_binary(ptr) == false)
{
- return MEMCACHED_NOT_SUPPORTED;
+ return memcached_set_error(*ptr, MEMCACHED_NOT_SUPPORTED, MEMCACHED_AT,
+ memcached_literal_param("ASCII protocol is not supported for memcached_mget_execute_by_key()"));
}
memcached_callback_st *original_callbacks= ptr->callbacks;
protocol_binary_request_getk request= { }; //= {.bytes= {0}};
request.message.header.request.magic= PROTOCOL_BINARY_REQ;
if (mget_mode)
+ {
request.message.header.request.opcode= PROTOCOL_BINARY_CMD_GETKQ;
+ }
else
+ {
request.message.header.request.opcode= PROTOCOL_BINARY_CMD_GETK;
+ }
memcached_return_t vk;
vk= memcached_validate_key_length(key_length[x],
ptr->flags.binary_protocol);
- unlikely (vk != MEMCACHED_SUCCESS)
+ if (vk != MEMCACHED_SUCCESS)
{
if (x > 0)
{
return NULL;
}
- if (memcached_failed(rc= memcached_validate_key_length(key_length, ptr->flags.binary_protocol)))
+ if (memcached_failed(rc= (memcached_key_test(*ptr, (const char **)&key, &key_length, 1))))
{
*error= rc;
return NULL;
}
- if (memcached_failed((memcached_key_test(*ptr, (const char **)&key, &key_length, 1))))
- {
- *error= MEMCACHED_BAD_KEY_PROVIDED;
- return NULL;
- }
-
uint32_t server_key= memcached_generate_hash(ptr, key, key_length);
return memcached_server_instance_by_position(ptr, server_key);
void memcached_server_error_reset(memcached_server_st *self)
{
WATCHPOINT_ASSERT(self);
- if (not self)
+ if (self == NULL)
{
return;
}
return rc;
}
- if (memcached_failed(rc= memcached_validate_key_length(key_length, memcached_is_binary(ptr))))
+ if (memcached_failed(rc= memcached_key_test(*ptr, (const char **)&key, &key_length, 1)))
{
return rc;
}
- if (memcached_failed(memcached_key_test(*ptr, (const char **)&key, &key_length, 1)))
- {
- return MEMCACHED_BAD_KEY_PROVIDED;
- }
-
uint32_t server_key= memcached_generate_hash_with_redistribution(ptr, group_key, group_key_length);
memcached_server_write_instance_st instance= memcached_server_instance_fetch(ptr, server_key);
if (memcached_failed(rc= memcached_validate_key_length(key_length, ptr->flags.binary_protocol)))
{
- return memcached_set_error(*ptr, rc, MEMCACHED_AT);
+ return rc;
}
uint32_t server_key= memcached_generate_hash_with_redistribution(ptr, group_key, group_key_length);
--- /dev/null
+/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
+ *
+ * Libmemcached library
+ *
+ * Copyright (C) 2012 Data Differential, http://datadifferential.com/
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * * The names of its contributors may not be used to endorse or
+ * promote products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+#include <config.h>
+#include <libtest/test.hpp>
+
+#include <libmemcached-1.0/memcached.h>
+#include <libmemcached/util.h>
+
+using namespace libtest;
+
+#include "tests/libmemcached-1.0/dump.h"
+
+static memcached_return_t callback_dump_counter(const memcached_st *,
+ const char *,
+ size_t ,
+ void *context)
+{
+ size_t *counter= (size_t *)context;
+
+ *counter= *counter +1;
+
+ return MEMCACHED_SUCCESS;
+}
+
+test_return_t memcached_dump_TEST(memcached_st *memc)
+{
+ test_skip(false, memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL));
+
+ size_t count= 0;
+ memcached_dump_fn callbacks[1];
+ callbacks[0]= &callback_dump_counter;
+
+ test_compare_hint(MEMCACHED_SUCCESS, memcached_dump(memc, callbacks, &count, 1), memcached_last_error_message(memc));
+
+ return TEST_SUCCESS;
+}
--- /dev/null
+/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
+ *
+ * Libmemcached library
+ *
+ * Copyright (C) 2012 Data Differential, http://datadifferential.com/
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * * The names of its contributors may not be used to endorse or
+ * promote products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+#pragma once
+
+test_return_t memcached_dump_TEST(memcached_st *);
tests/ketama.h \
tests/ketama_test_cases.h \
tests/ketama_test_cases_spy.h \
+ tests/libmemcached-1.0/dump.h \
tests/namespace.h \
tests/parser.h \
tests/touch.h \
tests/libmemcached-1.0/callbacks.cc \
tests/libmemcached-1.0/debug.cc \
tests/libmemcached-1.0/deprecated.cc \
+ tests/libmemcached-1.0/dump.cc \
tests/libmemcached-1.0/error_conditions.cc \
tests/libmemcached-1.0/exist.cc \
tests/libmemcached-1.0/ketama.cc \
#include "tests/ketama.h"
#include "tests/namespace.h"
#include "tests/parser.h"
+#include "tests/libmemcached-1.0/dump.h"
#include "tests/touch.h"
#include "tests/callbacks.h"
#include "tests/pool.h"
{"memcached_exist_by_key(MEMCACHED_SUCCESS)", true, (test_callback_fn*)memcached_exist_by_key_SUCCESS },
{"memcached_touch", 0, (test_callback_fn*)test_memcached_touch},
{"memcached_touch_with_prefix", 0, (test_callback_fn*)test_memcached_touch_by_key},
+ {"memcached_dump()", 0, (test_callback_fn*)memcached_dump_TEST },
{0, 0, 0}
};