+0.51
+
+ * memcached_callback_set() now takes its data argument as const
+
+
0.50 Mon Jun 20 10:36:57 PDT 2011
* Updates to C++ interface
* Custom free allocators need to now check for value before calling free.
#include <libmemcached/memcached.h>
-.. c:function:: memcached_return_t memcached_callback_set (memcached_st *ptr, memcached_callback_t flag, void *data);
+.. c:function:: memcached_return_t memcached_callback_set (memcached_st *ptr, memcached_callback_t flag, const void *data);
.. c:function:: void * memcached_callback_get (memcached_st *ptr, memcached_callback_t flag, memcached_return_t *error);
memcached_return_t memcached_callback_set(memcached_st *ptr,
const memcached_callback_t flag,
- void *data)
+ const void *data)
{
switch (flag)
{
}
case MEMCACHED_CALLBACK_USER_DATA:
{
- ptr->user_data= data;
+ ptr->user_data= const_cast<void *>(data);
break;
}
case MEMCACHED_CALLBACK_CLEANUP_FUNCTION:
LIBMEMCACHED_API
memcached_return_t memcached_callback_set(memcached_st *ptr,
const memcached_callback_t flag,
- void *data);
+ const void *data);
LIBMEMCACHED_API
void *memcached_callback_get(memcached_st *ptr,
const memcached_callback_t flag,
uint32_t *flags,
memcached_return_t *error)
{
+ memcached_return_t unused;
+ if (error == NULL)
+ error= &unused;
+
unlikely (ptr->flags.use_udp)
{
if (value_length)
/* Request the key */
*error= memcached_mget_by_key_real(ptr, group_key, group_key_length,
- (const char * const *)&key,
- &key_length, 1, false);
+ (const char * const *)&key, &key_length,
+ 1, false);
assert(ptr->query_id == query_id +1);
tests/ketama_test_cases.h \
tests/ketama_test_cases_spy.h \
tests/libmemcached_world.h \
+ tests/namespace.h \
tests/parser.h \
tests/deprecated.h \
tests/pool.h \
tests/deprecated.cc \
tests/error_conditions.cc \
tests/mem_functions.cc \
+ tests/namespace.cc \
tests/parser.cc \
tests/pool.cc \
tests/print.cc \
#include "tests/deprecated.h"
#include "tests/parser.h"
#include "tests/pool.h"
+#include "tests/namespace.h"
#include "tests/string.h"
#include "tests/replication.h"
#include "tests/basic.h"
test_st namespace_tests[] ={
{"basic tests", 0, (test_callback_fn*)selection_of_namespace_tests },
-#if 0
{"increment", 0, (test_callback_fn*)memcached_increment_namespace },
-#endif
{0, 0, (test_callback_fn*)0}
};
*/
#include <libtest/common.h>
+#include <libmemcached/memcached.h>
+#include <tests/namespace.h>
test_return_t memcached_increment_namespace(memcached_st *memc)
{
uint64_t new_number;
- memcached_return_t rc;
- const char *key= "number";
- const char *value= "0";
test_compare(MEMCACHED_SUCCESS,
memcached_set(memc,
memcached_st *clone= memcached_clone(NULL, memc);
+ test_compare(MEMCACHED_SUCCESS,
+ memcached_callback_set(clone, MEMCACHED_CALLBACK_NAMESPACE, "all_your_bases"));
+
test_compare(MEMCACHED_NOTFOUND,
- memcached_increment(memc,
+ memcached_increment(clone,
test_literal_param("number"),
1, &new_number));
- test_compare(1, new_number);
+ test_compare(MEMCACHED_SUCCESS,
+ memcached_add(clone,
+ test_literal_param("number"),
+ test_literal_param("10"),
+ (time_t)0, (uint32_t)0));
+
+ char *value= memcached_get(clone,
+ test_literal_param("number"),
+ 0, 0, 0);
+ test_true(value);
+ test_compare(2, strlen(value));
+ test_strcmp("10", value);
+
+ test_compare(MEMCACHED_SUCCESS,
+ memcached_increment(clone,
+ test_literal_param("number"),
+ 1, &new_number));
+ test_compare(11, new_number);
+
+ test_compare(MEMCACHED_SUCCESS,
+ memcached_increment(memc,
+ test_literal_param("number"),
+ 1, &new_number));
+ test_compare(3, new_number);
+ memcached_free(clone);
return TEST_SUCCESS;
}