return global_default_allocator;
}
-memcached_return_t memcached_set_memory_allocators(memcached_st *self,
+memcached_return_t memcached_set_memory_allocators(memcached_st *shell,
memcached_malloc_fn mem_malloc,
memcached_free_fn mem_free,
memcached_realloc_fn mem_realloc,
memcached_calloc_fn mem_calloc,
void *context)
{
+ Memcached* self= memcached2Memcached(shell);
if (self == NULL)
{
return MEMCACHED_INVALID_ARGUMENTS;
return MEMCACHED_SUCCESS;
}
-void *memcached_get_memory_allocators_context(const memcached_st *self)
+void *memcached_get_memory_allocators_context(const memcached_st *shell)
{
- return self->allocators.context;
+ const Memcached* self= memcached2Memcached(shell);
+ if (self)
+ {
+ return self->allocators.context;
+ }
+
+ return NULL;
}
-void memcached_get_memory_allocators(const memcached_st *self,
+void memcached_get_memory_allocators(const memcached_st *shell,
memcached_malloc_fn *mem_malloc,
memcached_free_fn *mem_free,
memcached_realloc_fn *mem_realloc,
memcached_calloc_fn *mem_calloc)
{
- if (self == NULL)
- {
- return;
- }
-
- if (mem_malloc)
- {
- *mem_malloc= self->allocators.malloc;
- }
-
- if (mem_free)
- {
- *mem_free= self->allocators.free;
- }
-
- if (mem_realloc)
- {
- *mem_realloc= self->allocators.realloc;
- }
-
- if (mem_calloc)
+ const Memcached* self= memcached2Memcached(shell);
+ if (self)
{
- *mem_calloc= self->allocators.calloc;
+ if (mem_malloc)
+ {
+ *mem_malloc= self->allocators.malloc;
+ }
+
+ if (mem_free)
+ {
+ *mem_free= self->allocators.free;
+ }
+
+ if (mem_realloc)
+ {
+ *mem_realloc= self->allocators.realloc;
+ }
+
+ if (mem_calloc)
+ {
+ *mem_calloc= self->allocators.calloc;
+ }
}
}
result->pool_hit_ratio= temp * 100;
}
-memcached_analysis_st *memcached_analyze(memcached_st *memc,
+memcached_analysis_st *memcached_analyze(memcached_st *shell,
memcached_stat_st *memc_stat,
memcached_return_t *error)
{
+ Memcached* memc= memcached2Memcached(shell);
uint64_t total_items= 0, total_bytes= 0;
uint64_t total_get_cmds= 0, total_get_hits= 0;
}
static memcached_return_t increment_decrement_by_key(const protocol_binary_command command,
- memcached_st *memc,
+ Memcached *memc,
const char *group_key, size_t group_key_length,
const char *key, size_t key_length,
uint64_t offset,
}
static memcached_return_t increment_decrement_with_initial_by_key(const protocol_binary_command command,
- memcached_st *memc,
+ Memcached *memc,
const char *group_key,
size_t group_key_length,
const char *key,
}
-memcached_return_t memcached_increment_by_key(memcached_st *memc,
+memcached_return_t memcached_increment_by_key(memcached_st *shell,
const char *group_key, size_t group_key_length,
const char *key, size_t key_length,
uint64_t offset,
uint64_t *value)
{
+ Memcached* memc= memcached2Memcached(shell);
LIBMEMCACHED_MEMCACHED_INCREMENT_START();
memcached_return_t rc= increment_decrement_by_key(PROTOCOL_BINARY_CMD_INCREMENT,
memc,
return rc;
}
-memcached_return_t memcached_decrement_by_key(memcached_st *memc,
+memcached_return_t memcached_decrement_by_key(memcached_st *shell,
const char *group_key, size_t group_key_length,
const char *key, size_t key_length,
uint64_t offset,
uint64_t *value)
{
+ Memcached* memc= memcached2Memcached(shell);
LIBMEMCACHED_MEMCACHED_DECREMENT_START();
memcached_return_t rc= increment_decrement_by_key(PROTOCOL_BINARY_CMD_DECREMENT,
memc,
offset, initial, expiration, value);
}
-memcached_return_t memcached_increment_with_initial_by_key(memcached_st *memc,
+memcached_return_t memcached_increment_with_initial_by_key(memcached_st *shell,
const char *group_key,
size_t group_key_length,
const char *key,
uint64_t *value)
{
LIBMEMCACHED_MEMCACHED_INCREMENT_WITH_INITIAL_START();
+ Memcached* memc= memcached2Memcached(shell);
memcached_return_t rc= increment_decrement_with_initial_by_key(PROTOCOL_BINARY_CMD_INCREMENT,
memc,
group_key, group_key_length,
offset, initial, expiration, value);
}
-memcached_return_t memcached_decrement_with_initial_by_key(memcached_st *memc,
+memcached_return_t memcached_decrement_with_initial_by_key(memcached_st *shell,
const char *group_key,
size_t group_key_length,
const char *key,
uint64_t *value)
{
LIBMEMCACHED_MEMCACHED_INCREMENT_WITH_INITIAL_START();
+ Memcached* memc= memcached2Memcached(shell);
memcached_return_t rc= increment_decrement_with_initial_by_key(PROTOCOL_BINARY_CMD_DECREMENT,
memc,
group_key, group_key_length,
#include <ctime>
#include <sys/types.h>
-bool memcached_is_consistent_distribution(const memcached_st* memc)
+bool memcached_is_consistent_distribution(const Memcached* memc)
{
switch (memc->distribution)
{
We quit all connections so we can reset the sockets.
*/
-memcached_return_t memcached_behavior_set(memcached_st *ptr,
+memcached_return_t memcached_behavior_set(memcached_st *shell,
const memcached_behavior_t flag,
uint64_t data)
{
+ Memcached* ptr= memcached2Memcached(shell);
if (ptr == NULL)
{
return MEMCACHED_INVALID_ARGUMENTS;
return ptr->flags.auto_eject_hosts;
}
-uint64_t memcached_behavior_get(memcached_st *ptr,
+uint64_t memcached_behavior_get(memcached_st *shell,
const memcached_behavior_t flag)
{
+ Memcached* ptr= memcached2Memcached(shell);
if (ptr == NULL)
{
return MEMCACHED_INVALID_ARGUMENTS;
}
-memcached_return_t memcached_behavior_set_distribution(memcached_st *ptr, memcached_server_distribution_t type)
+memcached_return_t memcached_behavior_set_distribution(memcached_st *shell, memcached_server_distribution_t type)
{
- switch (type)
+ Memcached* ptr= memcached2Memcached(shell);
+ if (ptr)
{
- case MEMCACHED_DISTRIBUTION_MODULA:
- break;
+ switch (type)
+ {
+ case MEMCACHED_DISTRIBUTION_MODULA:
+ break;
- case MEMCACHED_DISTRIBUTION_CONSISTENT:
- case MEMCACHED_DISTRIBUTION_CONSISTENT_KETAMA:
- memcached_set_weighted_ketama(ptr, false);
- break;
+ case MEMCACHED_DISTRIBUTION_CONSISTENT:
+ case MEMCACHED_DISTRIBUTION_CONSISTENT_KETAMA:
+ memcached_set_weighted_ketama(ptr, false);
+ break;
- case MEMCACHED_DISTRIBUTION_RANDOM:
- break;
+ case MEMCACHED_DISTRIBUTION_RANDOM:
+ break;
- case MEMCACHED_DISTRIBUTION_CONSISTENT_KETAMA_SPY:
- break;
+ case MEMCACHED_DISTRIBUTION_CONSISTENT_KETAMA_SPY:
+ break;
- case MEMCACHED_DISTRIBUTION_CONSISTENT_WEIGHTED:
- memcached_set_weighted_ketama(ptr, true);
- break;
+ case MEMCACHED_DISTRIBUTION_CONSISTENT_WEIGHTED:
+ memcached_set_weighted_ketama(ptr, true);
+ break;
- case MEMCACHED_DISTRIBUTION_VIRTUAL_BUCKET:
- break;
+ case MEMCACHED_DISTRIBUTION_VIRTUAL_BUCKET:
+ break;
- default:
- case MEMCACHED_DISTRIBUTION_CONSISTENT_MAX:
- return memcached_set_error(*ptr, MEMCACHED_INVALID_ARGUMENTS, MEMCACHED_AT,
- memcached_literal_param("Invalid memcached_server_distribution_t"));
+ default:
+ case MEMCACHED_DISTRIBUTION_CONSISTENT_MAX:
+ return memcached_set_error(*ptr, MEMCACHED_INVALID_ARGUMENTS, MEMCACHED_AT,
+ memcached_literal_param("Invalid memcached_server_distribution_t"));
+ }
+ ptr->distribution= type;
+
+ return run_distribution(ptr);
}
- ptr->distribution= type;
- return run_distribution(ptr);
+ return MEMCACHED_INVALID_ARGUMENTS;
}
-memcached_server_distribution_t memcached_behavior_get_distribution(memcached_st *ptr)
+memcached_server_distribution_t memcached_behavior_get_distribution(memcached_st *shell)
{
- return ptr->distribution;
+ Memcached* ptr= memcached2Memcached(shell);
+ if (ptr)
+ {
+ return ptr->distribution;
+ }
+
+ return MEMCACHED_DISTRIBUTION_CONSISTENT_MAX;
}
-memcached_return_t memcached_behavior_set_key_hash(memcached_st *ptr, memcached_hash_t type)
+memcached_return_t memcached_behavior_set_key_hash(memcached_st *shell, memcached_hash_t type)
{
- if (hashkit_success(hashkit_set_function(&ptr->hashkit, (hashkit_hash_algorithm_t)type)))
+ Memcached* ptr= memcached2Memcached(shell);
+ if (ptr)
{
- return MEMCACHED_SUCCESS;
+ if (hashkit_success(hashkit_set_function(&ptr->hashkit, (hashkit_hash_algorithm_t)type)))
+ {
+ return MEMCACHED_SUCCESS;
+ }
+
+ return memcached_set_error(*ptr, MEMCACHED_INVALID_ARGUMENTS, MEMCACHED_AT,
+ memcached_literal_param("Invalid memcached_hash_t()"));
}
- return memcached_set_error(*ptr, MEMCACHED_INVALID_ARGUMENTS, MEMCACHED_AT,
- memcached_literal_param("Invalid memcached_hash_t()"));
+ return MEMCACHED_INVALID_ARGUMENTS;
}
-memcached_hash_t memcached_behavior_get_key_hash(memcached_st *ptr)
+memcached_hash_t memcached_behavior_get_key_hash(memcached_st *shell)
{
- return (memcached_hash_t)hashkit_get_function(&ptr->hashkit);
+ Memcached* ptr= memcached2Memcached(shell);
+ if (ptr)
+ {
+ return (memcached_hash_t)hashkit_get_function(&ptr->hashkit);
+ }
+
+ return MEMCACHED_HASH_MAX;
}
-memcached_return_t memcached_behavior_set_distribution_hash(memcached_st *ptr, memcached_hash_t type)
+memcached_return_t memcached_behavior_set_distribution_hash(memcached_st *shell, memcached_hash_t type)
{
- if (hashkit_success(hashkit_set_distribution_function(&ptr->hashkit, (hashkit_hash_algorithm_t)type)))
+ Memcached* ptr= memcached2Memcached(shell);
+ if (ptr)
{
- return MEMCACHED_SUCCESS;
+ if (hashkit_success(hashkit_set_distribution_function(&ptr->hashkit, (hashkit_hash_algorithm_t)type)))
+ {
+ return MEMCACHED_SUCCESS;
+ }
+
+ return memcached_set_error(*ptr, MEMCACHED_INVALID_ARGUMENTS, MEMCACHED_AT,
+ memcached_literal_param("Invalid memcached_hash_t()"));
}
- return memcached_set_error(*ptr, MEMCACHED_INVALID_ARGUMENTS, MEMCACHED_AT,
- memcached_literal_param("Invalid memcached_hash_t()"));
+ return MEMCACHED_INVALID_ARGUMENTS;
}
-memcached_hash_t memcached_behavior_get_distribution_hash(memcached_st *ptr)
+memcached_hash_t memcached_behavior_get_distribution_hash(memcached_st *shell)
{
- return (memcached_hash_t)hashkit_get_function(&ptr->hashkit);
+ Memcached* ptr= memcached2Memcached(shell);
+ if (ptr)
+ {
+ return (memcached_hash_t)hashkit_get_function(&ptr->hashkit);
+ }
+
+ return MEMCACHED_HASH_MAX;
}
const char *libmemcached_string_behavior(const memcached_behavior_t flag)
}
}
-memcached_return_t memcached_bucket_set(memcached_st *self,
+memcached_return_t memcached_bucket_set(memcached_st *shell,
const uint32_t *host_map,
const uint32_t *forward_map,
const uint32_t buckets,
const uint32_t replicas)
{
+ Memcached* self= memcached2Memcached(shell);
memcached_return_t rc;
if (self == NULL)
These functions provide data and function callback support
*/
-memcached_return_t memcached_callback_set(memcached_st *ptr,
+memcached_return_t memcached_callback_set(memcached_st *shell,
const memcached_callback_t flag,
const void *data)
{
- switch (flag)
+ Memcached* ptr= memcached2Memcached(shell);
+ if (ptr)
{
- case MEMCACHED_CALLBACK_PREFIX_KEY:
+ switch (flag)
{
- return memcached_set_namespace(ptr, (char*)data, data ? strlen((char*)data) : 0);
- }
+ case MEMCACHED_CALLBACK_PREFIX_KEY:
+ {
+ return memcached_set_namespace(ptr, (char*)data, data ? strlen((char*)data) : 0);
+ }
- case MEMCACHED_CALLBACK_USER_DATA:
- {
- ptr->user_data= const_cast<void *>(data);
- break;
- }
+ case MEMCACHED_CALLBACK_USER_DATA:
+ {
+ ptr->user_data= const_cast<void *>(data);
+ break;
+ }
- case MEMCACHED_CALLBACK_CLEANUP_FUNCTION:
- {
- memcached_cleanup_fn func= *(memcached_cleanup_fn *)&data;
- ptr->on_cleanup= func;
- break;
- }
+ case MEMCACHED_CALLBACK_CLEANUP_FUNCTION:
+ {
+ memcached_cleanup_fn func= *(memcached_cleanup_fn *)&data;
+ ptr->on_cleanup= func;
+ break;
+ }
- case MEMCACHED_CALLBACK_CLONE_FUNCTION:
- {
- memcached_clone_fn func= *(memcached_clone_fn *)&data;
- ptr->on_clone= func;
- break;
- }
+ case MEMCACHED_CALLBACK_CLONE_FUNCTION:
+ {
+ memcached_clone_fn func= *(memcached_clone_fn *)&data;
+ ptr->on_clone= func;
+ break;
+ }
- case MEMCACHED_CALLBACK_GET_FAILURE:
- {
- memcached_trigger_key_fn func= *(memcached_trigger_key_fn *)&data;
- ptr->get_key_failure= func;
- break;
- }
+ case MEMCACHED_CALLBACK_GET_FAILURE:
+ {
+ memcached_trigger_key_fn func= *(memcached_trigger_key_fn *)&data;
+ ptr->get_key_failure= func;
+ break;
+ }
- case MEMCACHED_CALLBACK_DELETE_TRIGGER:
- {
- if (data) // NULL would mean we are disabling.
+ case MEMCACHED_CALLBACK_DELETE_TRIGGER:
{
- if (memcached_behavior_get(ptr, MEMCACHED_BEHAVIOR_BUFFER_REQUESTS))
+ if (data) // NULL would mean we are disabling.
{
- return memcached_set_error(*ptr, MEMCACHED_INVALID_ARGUMENTS, MEMCACHED_AT, memcached_literal_param("Delete triggers cannot be used if buffering is enabled"));
+ if (memcached_behavior_get(ptr, MEMCACHED_BEHAVIOR_BUFFER_REQUESTS))
+ {
+ return memcached_set_error(*ptr, MEMCACHED_INVALID_ARGUMENTS, MEMCACHED_AT, memcached_literal_param("Delete triggers cannot be used if buffering is enabled"));
+ }
+
+ if (memcached_behavior_get(ptr, MEMCACHED_BEHAVIOR_NOREPLY))
+ {
+ return memcached_set_error(*ptr, MEMCACHED_INVALID_ARGUMENTS, MEMCACHED_AT, memcached_literal_param("Delete triggers cannot be used if MEMCACHED_BEHAVIOR_NOREPLY is set"));
+ }
}
- if (memcached_behavior_get(ptr, MEMCACHED_BEHAVIOR_NOREPLY))
- {
- return memcached_set_error(*ptr, MEMCACHED_INVALID_ARGUMENTS, MEMCACHED_AT, memcached_literal_param("Delete triggers cannot be used if MEMCACHED_BEHAVIOR_NOREPLY is set"));
- }
+ memcached_trigger_delete_key_fn func= *(memcached_trigger_delete_key_fn *)&data;
+ ptr->delete_trigger= func;
+ break;
}
- memcached_trigger_delete_key_fn func= *(memcached_trigger_delete_key_fn *)&data;
- ptr->delete_trigger= func;
- break;
+ case MEMCACHED_CALLBACK_MAX:
+ return memcached_set_error(*ptr, MEMCACHED_INVALID_ARGUMENTS, MEMCACHED_AT, memcached_literal_param("Invalid callback supplied"));
}
- case MEMCACHED_CALLBACK_MAX:
- return memcached_set_error(*ptr, MEMCACHED_INVALID_ARGUMENTS, MEMCACHED_AT, memcached_literal_param("Invalid callback supplied"));
+ return MEMCACHED_SUCCESS;
}
- return MEMCACHED_SUCCESS;
+ return MEMCACHED_INVALID_ARGUMENTS;
}
-void *memcached_callback_get(memcached_st *ptr,
+void *memcached_callback_get(memcached_st *shell,
const memcached_callback_t flag,
memcached_return_t *error)
{
+ Memcached* ptr= memcached2Memcached(shell);
memcached_return_t local_error;
if (error == NULL)
{
#include <libmemcached-1.0/memcached.h>
#include <libmemcached/watchpoint.h>
#include <libmemcached/is.h>
+typedef struct memcached_st Memcached;
#ifdef __cplusplus
# include "libmemcached/instance.hpp"
#include <libmemcached/common.h>
#include <libmemcached/memcached/protocol_binary.h>
-memcached_return_t memcached_delete(memcached_st *memc, const char *key, size_t key_length,
+memcached_return_t memcached_delete(memcached_st *shell, const char *key, size_t key_length,
time_t expiration)
{
- return memcached_delete_by_key(memc, key, key_length, key, key_length, expiration);
+ return memcached_delete_by_key(shell, key, key_length, key, key_length, expiration);
}
static inline memcached_return_t ascii_delete(org::libmemcached::Instance* instance,
return rc;
}
-memcached_return_t memcached_delete_by_key(memcached_st *memc,
+memcached_return_t memcached_delete_by_key(memcached_st *shell,
const char *group_key, size_t group_key_length,
const char *key, size_t key_length,
time_t expiration)
{
+ Memcached* memc= memcached2Memcached(shell);
LIBMEMCACHED_MEMCACHED_DELETE_START();
memcached_return_t rc;
#include <libmemcached/common.h>
-static memcached_return_t ascii_dump(memcached_st *memc, memcached_dump_fn *callback, void *context, uint32_t number_of_callbacks)
+static memcached_return_t ascii_dump(Memcached *memc, memcached_dump_fn *callback, void *context, uint32_t number_of_callbacks)
{
/* MAX_NUMBER_OF_SLAB_CLASSES is defined to 200 in Memcached 1.4.10 */
for (uint32_t x= 0; x < 200; x++)
return memcached_has_current_error(*memc) ? MEMCACHED_SOME_ERRORS : MEMCACHED_SUCCESS;
}
-memcached_return_t memcached_dump(memcached_st *ptr, memcached_dump_fn *callback, void *context, uint32_t number_of_callbacks)
+memcached_return_t memcached_dump(memcached_st *shell, memcached_dump_fn *callback, void *context, uint32_t number_of_callbacks)
{
+ Memcached* ptr= memcached2Memcached(shell);
memcached_return_t rc;
if (memcached_failed(rc= initialize_query(ptr, true)))
{
#include <libmemcached/common.h>
#include <libmemcached/assert.hpp>
-static void _set_encoding_key(memcached_st& self, const char *key, size_t key_length)
+static void _set_encoding_key(Memcached& self, const char *key, size_t key_length)
{
hashkit_key(&self.hashkit, key, key_length);
}
-memcached_return_t memcached_set_encoding_key(memcached_st* self, const char *key, size_t key_length)
+memcached_return_t memcached_set_encoding_key(memcached_st* shell, const char *key, size_t key_length)
{
+ Memcached* self= memcached2Memcached(shell);
if (self == NULL)
{
return MEMCACHED_INVALID_ARGUMENTS;
char message[MAX_ERROR_LENGTH];
};
-static void _set(org::libmemcached::Instance& server, memcached_st& memc)
+static void _set(org::libmemcached::Instance& server, Memcached& memc)
{
if (server.error_messages and server.error_messages->query_id != server.root->query_id)
{
_error_print(error->next);
}
-void memcached_error_print(const memcached_st *self)
+void memcached_error_print(const memcached_st *shell)
{
+ const Memcached* self= memcached2Memcached(shell);
if (self == NULL)
{
return;
return memcached_last_error_message(memc);
}
-const char *memcached_last_error_message(const memcached_st *memc)
+const char *memcached_last_error_message(const memcached_st *shell)
{
+ const Memcached* memc= memcached2Memcached(shell);
if (memc)
{
if (memc->error_messages)
return memcached_has_current_error(*(server.root));
}
-memcached_return_t memcached_last_error(const memcached_st *memc)
+memcached_return_t memcached_last_error(const memcached_st *shell)
{
+ const Memcached* memc= memcached2Memcached(shell);
if (memc)
{
if (memc->error_messages)
return MEMCACHED_INVALID_ARGUMENTS;
}
-int memcached_last_error_errno(const memcached_st *memc)
+int memcached_last_error_errno(const memcached_st *shell)
{
+ const Memcached* memc= memcached2Memcached(shell);
if (memc == NULL)
{
return 0;
#include <libmemcached/common.h>
-static memcached_return_t ascii_exist(memcached_st *memc, org::libmemcached::Instance* instance, const char *key, size_t key_length)
+static memcached_return_t ascii_exist(Memcached *memc, org::libmemcached::Instance* instance, const char *key, size_t key_length)
{
libmemcached_io_vector_st vector[]=
{
return rc;
}
-static memcached_return_t binary_exist(memcached_st *memc, org::libmemcached::Instance* instance, const char *key, size_t key_length)
+static memcached_return_t binary_exist(Memcached *memc, org::libmemcached::Instance* instance, const char *key, size_t key_length)
{
protocol_binary_request_set request= {};
size_t send_length= sizeof(request.bytes);
return memcached_exist_by_key(memc, key, key_length, key, key_length);
}
-memcached_return_t memcached_exist_by_key(memcached_st *memc,
+memcached_return_t memcached_exist_by_key(memcached_st *shell,
const char *group_key, size_t group_key_length,
const char *key, size_t key_length)
{
+ Memcached* memc= memcached2Memcached(shell);
memcached_return_t rc;
if (memcached_failed(rc= initialize_query(memc, true)))
{
#include <libmemcached/common.h>
-char *memcached_fetch(memcached_st *ptr, char *key, size_t *key_length,
+char *memcached_fetch(memcached_st *shell, char *key, size_t *key_length,
size_t *value_length,
uint32_t *flags,
memcached_return_t *error)
{
+ Memcached* ptr= memcached2Memcached(shell);
memcached_return_t unused;
if (error == NULL)
{
return NULL;
}
-memcached_return_t memcached_fetch_execute(memcached_st *ptr,
+memcached_return_t memcached_fetch_execute(memcached_st *shell,
memcached_execute_fn *callback,
void *context,
uint32_t number_of_callbacks)
{
+ Memcached* ptr= memcached2Memcached(shell);
memcached_result_st *result= &ptr->result;
memcached_return_t rc;
bool some_errors= false;
#include <libmemcached/common.h>
-static memcached_return_t memcached_flush_binary(memcached_st *ptr,
+static memcached_return_t memcached_flush_binary(Memcached *ptr,
time_t expiration,
const bool reply)
{
return rc;
}
-static memcached_return_t memcached_flush_textual(memcached_st *ptr,
+static memcached_return_t memcached_flush_textual(Memcached *ptr,
time_t expiration,
const bool reply)
{
return rc;
}
-memcached_return_t memcached_flush(memcached_st *ptr, time_t expiration)
+memcached_return_t memcached_flush(memcached_st *shell, time_t expiration)
{
+ Memcached* ptr= memcached2Memcached(shell);
memcached_return_t rc;
if (memcached_failed(rc= initialize_query(ptr, true)))
{
#include <libmemcached/common.h>
-memcached_return_t memcached_flush_buffers(memcached_st *memc)
+memcached_return_t memcached_flush_buffers(memcached_st *shell)
{
- memcached_return_t ret= MEMCACHED_SUCCESS;
-
- for (uint32_t x= 0; x < memcached_server_count(memc); ++x)
+ Memcached* memc= memcached2Memcached(shell);
+ if (memc)
{
- org::libmemcached::Instance* instance= memcached_instance_fetch(memc, x);
+ memcached_return_t ret= MEMCACHED_SUCCESS;
- if (instance->write_buffer_offset != 0)
+ for (uint32_t x= 0; x < memcached_server_count(memc); ++x)
{
- if (instance->fd == INVALID_SOCKET and
- (ret= memcached_connect(instance)) != MEMCACHED_SUCCESS)
- {
- WATCHPOINT_ERROR(ret);
- return ret;
- }
+ org::libmemcached::Instance* instance= memcached_instance_fetch(memc, x);
- if (memcached_io_write(instance) == false)
+ if (instance->write_buffer_offset != 0)
{
- ret= MEMCACHED_SOME_ERRORS;
+ if (instance->fd == INVALID_SOCKET and
+ (ret= memcached_connect(instance)) != MEMCACHED_SUCCESS)
+ {
+ WATCHPOINT_ERROR(ret);
+ return ret;
+ }
+
+ if (memcached_io_write(instance) == false)
+ {
+ ret= MEMCACHED_SOME_ERRORS;
+ }
}
}
+
+ return ret;
}
- return ret;
+ return MEMCACHED_INVALID_ARGUMENTS;
}
size_t number_of_keys,
bool mget_mode);
-char *memcached_get_by_key(memcached_st *ptr,
+char *memcached_get_by_key(memcached_st *shell,
const char *group_key,
size_t group_key_length,
const char *key, size_t key_length,
uint32_t *flags,
memcached_return_t *error)
{
+ Memcached* ptr= memcached2Memcached(shell);
memcached_return_t unused;
if (error == NULL)
{
return MEMCACHED_FAILURE; // Complete failure occurred
}
-memcached_return_t memcached_mget_by_key(memcached_st *ptr,
+memcached_return_t memcached_mget_by_key(memcached_st *shell,
const char *group_key,
size_t group_key_length,
const char * const *keys,
const size_t *key_length,
size_t number_of_keys)
{
+ Memcached* ptr= memcached2Memcached(shell);
return memcached_mget_by_key_real(ptr, group_key, group_key_length, keys,
key_length, number_of_keys, true);
}
context, number_of_callbacks);
}
-memcached_return_t memcached_mget_execute_by_key(memcached_st *ptr,
+memcached_return_t memcached_mget_execute_by_key(memcached_st *shell,
const char *group_key,
size_t group_key_length,
const char * const *keys,
void *context,
unsigned int number_of_callbacks)
{
+ Memcached* ptr= memcached2Memcached(shell);
memcached_return_t rc;
if (memcached_failed(rc= initialize_query(ptr, false)))
{
return libhashkit_digest(key, key_length, (hashkit_hash_algorithm_t)hash_algorithm);
}
-static inline uint32_t generate_hash(const memcached_st *ptr, const char *key, size_t key_length)
+static inline uint32_t generate_hash(const Memcached *ptr, const char *key, size_t key_length)
{
return hashkit_digest(&ptr->hashkit, key, key_length);
}
-static uint32_t dispatch_host(const memcached_st *ptr, uint32_t hash)
+static uint32_t dispatch_host(const Memcached *ptr, uint32_t hash)
{
switch (ptr->distribution)
{
/*
One version is public and will not modify the distribution hash, the other will.
*/
-static inline uint32_t _generate_hash_wrapper(const memcached_st *ptr, const char *key, size_t key_length)
+static inline uint32_t _generate_hash_wrapper(const Memcached *ptr, const char *key, size_t key_length)
{
WATCHPOINT_ASSERT(memcached_server_count(ptr));
}
}
-static inline void _regen_for_auto_eject(memcached_st *ptr)
+static inline void _regen_for_auto_eject(Memcached *ptr)
{
if (_is_auto_eject_host(ptr) && ptr->ketama.next_distribution_rebuild)
{
return dispatch_host(ptr, hash);
}
-uint32_t memcached_generate_hash(const memcached_st *ptr, const char *key, size_t key_length)
+uint32_t memcached_generate_hash(const memcached_st *shell, const char *key, size_t key_length)
{
- return dispatch_host(ptr, _generate_hash_wrapper(ptr, key, key_length));
+ const Memcached* ptr= memcached2Memcached(shell);
+ if (ptr)
+ {
+ return dispatch_host(ptr, _generate_hash_wrapper(ptr, key, key_length));
+ }
+
+ return UINT32_MAX;
}
-const hashkit_st *memcached_get_hashkit(const memcached_st *ptr)
+const hashkit_st *memcached_get_hashkit(const memcached_st *shell)
{
- return &ptr->hashkit;
+ const Memcached* ptr= memcached2Memcached(shell);
+ if (ptr)
+ {
+ return &ptr->hashkit;
+ }
+
+ return NULL;
}
-memcached_return_t memcached_set_hashkit(memcached_st *self, hashkit_st *hashk)
+memcached_return_t memcached_set_hashkit(memcached_st *shell, hashkit_st *hashk)
{
- hashkit_free(&self->hashkit);
- hashkit_clone(&self->hashkit, hashk);
+ Memcached* self= memcached2Memcached(shell);
+ if (self)
+ {
+ hashkit_free(&self->hashkit);
+ hashkit_clone(&self->hashkit, hashk);
+
+ return MEMCACHED_SUCCESS;
+ }
- return MEMCACHED_SUCCESS;
+ return MEMCACHED_INVALID_ARGUMENTS;
}
const char * libmemcached_string_hash(memcached_hash_t type)
#include <sys/time.h>
/* Protoypes (static) */
-static memcached_return_t update_continuum(memcached_st *ptr);
+static memcached_return_t update_continuum(Memcached *ptr);
static int compare_servers(const void *p1, const void *p2)
{
return return_value;
}
-static void sort_hosts(memcached_st *ptr)
+static void sort_hosts(Memcached *ptr)
{
if (memcached_server_count(ptr))
{
}
-memcached_return_t run_distribution(memcached_st *ptr)
+memcached_return_t run_distribution(Memcached *ptr)
{
if (ptr->flags.use_sort_hosts)
{
}
}
-static memcached_return_t update_continuum(memcached_st *ptr)
+static memcached_return_t update_continuum(Memcached *ptr)
{
uint32_t continuum_index= 0;
uint32_t pointer_counter= 0;
return MEMCACHED_SUCCESS;
}
-static memcached_return_t server_add(memcached_st *memc,
+static memcached_return_t server_add(Memcached *memc,
const memcached_string_t& hostname,
in_port_t port,
uint32_t weight,
}
-memcached_return_t memcached_server_push(memcached_st *ptr, const memcached_server_list_st list)
+memcached_return_t memcached_server_push(memcached_st *shell, const memcached_server_list_st list)
{
if (list == NULL)
{
return MEMCACHED_SUCCESS;
}
- uint32_t original_host_size= memcached_server_count(ptr);
- uint32_t count= memcached_server_list_count(list);
- uint32_t host_list_size= count +original_host_size;
-
- org::libmemcached::Instance* new_host_list= libmemcached_xrealloc(ptr, memcached_instance_list(ptr), host_list_size, org::libmemcached::Instance);
-
- if (new_host_list == NULL)
+ Memcached* ptr= memcached2Memcached(shell);
+ if (ptr)
{
- return MEMCACHED_MEMORY_ALLOCATION_FAILURE;
- }
+ uint32_t original_host_size= memcached_server_count(ptr);
+ uint32_t count= memcached_server_list_count(list);
+ uint32_t host_list_size= count +original_host_size;
- memcached_instance_set(ptr, new_host_list, host_list_size);
+ org::libmemcached::Instance* new_host_list= libmemcached_xrealloc(ptr, memcached_instance_list(ptr), host_list_size, org::libmemcached::Instance);
- ptr->state.is_parsing= true;
- for (uint32_t x= 0; x < count; ++x, ++original_host_size)
- {
- WATCHPOINT_ASSERT(list[x].hostname[0] != 0);
-
- // We have extended the array, and now we will find it, and use it.
- org::libmemcached::Instance* instance= memcached_instance_fetch(ptr, original_host_size);
- WATCHPOINT_ASSERT(instance);
-
- memcached_string_t hostname= { memcached_string_make_from_cstr(list[x].hostname) };
- if (__instance_create_with(ptr, instance,
- hostname,
- list[x].port, list[x].weight, list[x].type) == NULL)
+ if (new_host_list == NULL)
{
- ptr->state.is_parsing= false;
- return memcached_set_error(*ptr, MEMCACHED_MEMORY_ALLOCATION_FAILURE, MEMCACHED_AT);
+ return MEMCACHED_MEMORY_ALLOCATION_FAILURE;
}
- if (list[x].weight > 1)
+ memcached_instance_set(ptr, new_host_list, host_list_size);
+
+ ptr->state.is_parsing= true;
+ for (uint32_t x= 0; x < count; ++x, ++original_host_size)
{
- memcached_set_weighted_ketama(ptr, true);
+ WATCHPOINT_ASSERT(list[x].hostname[0] != 0);
+
+ // We have extended the array, and now we will find it, and use it.
+ org::libmemcached::Instance* instance= memcached_instance_fetch(ptr, original_host_size);
+ WATCHPOINT_ASSERT(instance);
+
+ memcached_string_t hostname= { memcached_string_make_from_cstr(list[x].hostname) };
+ if (__instance_create_with(ptr, instance,
+ hostname,
+ list[x].port, list[x].weight, list[x].type) == NULL)
+ {
+ ptr->state.is_parsing= false;
+ return memcached_set_error(*ptr, MEMCACHED_MEMORY_ALLOCATION_FAILURE, MEMCACHED_AT);
+ }
+
+ if (list[x].weight > 1)
+ {
+ memcached_set_weighted_ketama(ptr, true);
+ }
}
+ ptr->state.is_parsing= false;
+
+ return run_distribution(ptr);
}
- ptr->state.is_parsing= false;
- return run_distribution(ptr);
+ return MEMCACHED_INVALID_ARGUMENTS;
}
memcached_return_t memcached_instance_push(memcached_st *ptr, const struct org::libmemcached::Instance* list, uint32_t number_of_hosts)
return memcached_server_add_unix_socket_with_weight(ptr, filename, 0);
}
-memcached_return_t memcached_server_add_unix_socket_with_weight(memcached_st *ptr,
+memcached_return_t memcached_server_add_unix_socket_with_weight(memcached_st *shell,
const char *filename,
uint32_t weight)
{
- if (ptr == NULL)
+ Memcached* ptr= memcached2Memcached(shell);
+ if (ptr)
{
- return MEMCACHED_FAILURE;
- }
+ memcached_string_t _filename= { memcached_string_make_from_cstr(filename) };
+ if (memcached_is_valid_filename(_filename) == false)
+ {
+ return memcached_set_error(*ptr, MEMCACHED_INVALID_ARGUMENTS, MEMCACHED_AT, memcached_literal_param("Invalid filename for socket provided"));
+ }
- memcached_string_t _filename= { memcached_string_make_from_cstr(filename) };
- if (memcached_is_valid_filename(_filename) == false)
- {
- return memcached_set_error(*ptr, MEMCACHED_INVALID_ARGUMENTS, MEMCACHED_AT, memcached_literal_param("Invalid filename for socket provided"));
+ return server_add(ptr, _filename, 0, weight, MEMCACHED_CONNECTION_UNIX_SOCKET);
}
- return server_add(ptr, _filename, 0, weight, MEMCACHED_CONNECTION_UNIX_SOCKET);
+ return MEMCACHED_FAILURE;
}
memcached_return_t memcached_server_add_udp(memcached_st *ptr,
return memcached_server_add_udp_with_weight(ptr, hostname, port, 0);
}
-memcached_return_t memcached_server_add_udp_with_weight(memcached_st *ptr,
+memcached_return_t memcached_server_add_udp_with_weight(memcached_st *shell,
const char *,
in_port_t,
uint32_t)
{
- if (ptr == NULL)
+ Memcached* self= memcached2Memcached(shell);
+ if (self)
{
- return MEMCACHED_INVALID_ARGUMENTS;
+ return memcached_set_error(*self, MEMCACHED_DEPRECATED, MEMCACHED_AT);
}
- return memcached_set_error(*ptr, MEMCACHED_DEPRECATED, MEMCACHED_AT);
+ return MEMCACHED_INVALID_ARGUMENTS;
}
-memcached_return_t memcached_server_add(memcached_st *ptr,
+memcached_return_t memcached_server_add(memcached_st *shell,
const char *hostname,
in_port_t port)
{
- return memcached_server_add_with_weight(ptr, hostname, port, 0);
+ return memcached_server_add_with_weight(shell, hostname, port, 0);
}
-memcached_return_t memcached_server_add_with_weight(memcached_st *ptr,
+memcached_return_t memcached_server_add_with_weight(memcached_st *shell,
const char *hostname,
in_port_t port,
uint32_t weight)
{
+ Memcached* ptr= memcached2Memcached(shell);
if (ptr == NULL)
{
return MEMCACHED_INVALID_ARGUMENTS;
#include <libmemcached/common.h>
-memcached_return_t initialize_query(memcached_st *self, bool increment_query_id)
+memcached_return_t initialize_query(Memcached *self, bool increment_query_id)
{
if (self == NULL)
{
return MEMCACHED_SUCCESS;
}
-memcached_return_t initialize_const_query(const memcached_st *self)
+memcached_return_t initialize_const_query(const Memcached *self)
{
if (self == NULL)
{
#include <libmemcached/common.h>
-static inline void _server_init(org::libmemcached::Instance* self, memcached_st *root,
+static inline void _server_init(org::libmemcached::Instance* self, Memcached *root,
const memcached_string_t& hostname,
in_port_t port,
uint32_t weight, memcached_connection_t type)
}
}
-memcached_return_t memcached_server_cursor(const memcached_st* memc,
+memcached_return_t memcached_server_cursor(const memcached_st* shell,
const memcached_server_fn *callback,
void *context,
uint32_t number_of_callbacks)
{
+ const Memcached* memc= memcached2Memcached(shell);
memcached_return_t rc;
if (memcached_failed(rc= initialize_const_query(memc)))
{
return MEMCACHED_SUCCESS;
}
-memcached_server_instance_st memcached_server_by_key(memcached_st *memc,
+memcached_server_instance_st memcached_server_by_key(memcached_st *shell,
const char *key,
size_t key_length,
memcached_return_t *error)
{
+ Memcached* memc= memcached2Memcached(shell);
memcached_return_t unused;
if (error == NULL)
{
}
}
-memcached_server_instance_st memcached_server_get_last_disconnect(const memcached_st *self)
+memcached_server_instance_st memcached_server_get_last_disconnect(const memcached_st *shell)
{
- WATCHPOINT_ASSERT(self);
- if (self == NULL)
+ const Memcached* self= memcached2Memcached(shell);
+ if (self)
{
- return 0;
+ return (memcached_server_instance_st)self->last_disconnected_server;
}
- return (memcached_server_instance_st)self->last_disconnected_server;
+ return 0;
}
void memcached_instance_next_retry(memcached_server_instance_st self, const time_t absolute_time)
*/
memcached_callback_st cb= *instance->root->callbacks;
- memcached_set_processing_input((memcached_st *)instance->root, true);
+ memcached_set_processing_input((Memcached *)instance->root, true);
char buffer[MEMCACHED_DEFAULT_COMMAND_SIZE];
- memcached_st *root= (memcached_st *)instance->root;
+ Memcached *root= (Memcached *)instance->root;
memcached_return_t error= memcached_response(instance, buffer, sizeof(buffer), &root->result);
memcached_set_processing_input(root, false);
major_version= minor_version= micro_version= UINT8_MAX;
}
-org::libmemcached::Instance* memcached_io_get_readable_server(memcached_st *memc, memcached_return_t&)
+org::libmemcached::Instance* memcached_io_get_readable_server(Memcached *memc, memcached_return_t&)
{
#define MAX_SERVERS_TO_POLL 100
struct pollfd fds[MAX_SERVERS_TO_POLL];
#define memcached_set_allocated(__object, __value) ((__object)->options.is_allocated= (__value))
#define memcached_set_weighted_ketama(__object, __value) ((__object)->ketama.weighted_= (__value))
+
+#define memcached2Memcached(__obj) (__obj)
#include <libmemcached/options.hpp>
#include <libmemcached/virtual_bucket.h>
-static inline bool _memcached_init(memcached_st *self)
+static inline bool _memcached_init(Memcached *self)
{
self->state.is_purging= false;
self->state.is_processing_input= false;
return true;
}
-static void __memcached_free(memcached_st *ptr, bool release_st)
+static void __memcached_free(Memcached *ptr, bool release_st)
{
/* If we have anything open, lets close it now */
send_quit(ptr);
}
}
-memcached_st *memcached_create(memcached_st *ptr)
+memcached_st *memcached_create(memcached_st *shell)
{
+ Memcached* ptr= memcached2Memcached(shell);
if (ptr)
{
ptr->options.is_allocated= false;
return memc;
}
-memcached_return_t memcached_reset(memcached_st *ptr)
+memcached_return_t memcached_reset(memcached_st *shell)
{
+ Memcached* ptr= memcached2Memcached(shell);
WATCHPOINT_ASSERT(ptr);
if (ptr == NULL)
{
return MEMCACHED_SUCCESS;
}
-void memcached_servers_reset(memcached_st *self)
+void memcached_servers_reset(memcached_st *shell)
{
+ Memcached* self= memcached2Memcached(shell);
if (self)
{
libmemcached_free(self, self->ketama.continuum);
}
}
-void memcached_reset_last_disconnected_server(memcached_st *self)
+void memcached_reset_last_disconnected_server(memcached_st *shell)
{
+ Memcached* self= memcached2Memcached(shell);
if (self)
{
memcached_instance_free((org::libmemcached::Instance*)self->last_disconnected_server);
return new_clone;
}
-void *memcached_get_user_data(const memcached_st *ptr)
+void *memcached_get_user_data(const memcached_st *shell)
{
- if (ptr == NULL)
+ const Memcached* memc= memcached2Memcached(shell);
+ if (memc)
{
- return NULL;
+ return memc->user_data;
}
- return ptr->user_data;
+ return NULL;
}
-void *memcached_set_user_data(memcached_st *ptr, void *data)
+void *memcached_set_user_data(memcached_st *shell, void *data)
{
- if (ptr == NULL)
+ Memcached* memc= memcached2Memcached(shell);
+ if (memc)
{
- return NULL;
- }
+ void *ret= memc->user_data;
+ memc->user_data= data;
- void *ret= ptr->user_data;
- ptr->user_data= data;
+ return ret;
+ }
- return ret;
+ return NULL;
}
memcached_return_t memcached_push(memcached_st *destination, const memcached_st *source)
return memcached_instance_push(destination, (org::libmemcached::Instance*)source->servers, source->number_of_hosts);
}
-org::libmemcached::Instance* memcached_instance_fetch(memcached_st *ptr, uint32_t server_key)
+org::libmemcached::Instance* memcached_instance_fetch(Memcached *ptr, uint32_t server_key)
{
if (ptr == NULL)
{
return &ptr->servers[server_key];
}
-memcached_server_instance_st memcached_server_instance_by_position(const memcached_st *ptr, uint32_t server_key)
+memcached_server_instance_st memcached_server_instance_by_position(const memcached_st *shell, uint32_t server_key)
{
- if (ptr == NULL)
+ const Memcached* memc= memcached2Memcached(shell);
+ if (memc)
{
- return NULL;
+ return &memc->servers[server_key];
}
- return &ptr->servers[server_key];
+ return NULL;
}
-org::libmemcached::Instance* memcached_instance_by_position(const memcached_st *ptr, uint32_t server_key)
+org::libmemcached::Instance* memcached_instance_by_position(const memcached_st *shell, uint32_t server_key)
{
- if (ptr == NULL)
+ const Memcached* memc= memcached2Memcached(shell);
+ if (memc)
{
- return NULL;
+ return &memc->servers[server_key];
}
- return &ptr->servers[server_key];
+ return NULL;
}
-uint64_t memcached_query_id(const memcached_st *self)
+uint64_t memcached_query_id(const memcached_st *shell)
{
- if (self == NULL)
+ const Memcached* memc= memcached2Memcached(shell);
+ if (memc)
{
- return 0;
+ return memc->query_id;
}
- return self->query_id;
+ return 0;
}
-org::libmemcached::Instance* memcached_instance_list(const memcached_st *self)
+org::libmemcached::Instance* memcached_instance_list(const memcached_st *shell)
{
- if (self)
+ const Memcached* memc= memcached2Memcached(shell);
+ if (memc)
{
- return (org::libmemcached::Instance*)self->servers;
+ return (org::libmemcached::Instance*)memc->servers;
}
return NULL;
class Purge
{
public:
- Purge(memcached_st* arg) :
+ Purge(Memcached* arg) :
_memc(arg)
{
memcached_set_purging(_memc, true);
}
private:
- memcached_st* _memc;
+ Memcached* _memc;
};
class PollTimeout
{
public:
- PollTimeout(memcached_st* arg) :
+ PollTimeout(Memcached* arg) :
_timeout(arg->poll_timeout),
_origin(arg->poll_timeout)
{
bool memcached_purge(org::libmemcached::Instance* ptr)
{
- memcached_st *root= (memcached_st *)ptr->root;
+ Memcached *root= (Memcached *)ptr->root;
if (memcached_is_purging(ptr->root) || /* already purging */
(memcached_server_response_count(ptr) < ptr->root->io_msg_watermark &&
}
}
-void send_quit(memcached_st *memc)
+void send_quit(Memcached *memc)
{
for (uint32_t x= 0; x < memcached_server_count(memc); x++)
{
}
}
-void memcached_quit(memcached_st *memc)
+void memcached_quit(memcached_st *shell)
{
+ Memcached* memc= memcached2Memcached(shell);
memcached_return_t rc;
if (memcached_failed(rc= initialize_query(memc, true)))
{
if (result == NULL)
{
- memcached_st *root= (memcached_st *)instance->root;
+ Memcached *root= (Memcached *)instance->root;
result = &root->result;
}
*
* Libmemcached library
*
- * Copyright (C) 2011 Data Differential, http://datadifferential.com/
+ * Copyright (C) 2011-2013 Data Differential, http://datadifferential.com/
* Copyright (C) 2006-2009 Brian Aker All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
#include <libmemcached/common.h>
static inline void _result_init(memcached_result_st *self,
- memcached_st *memc)
+ Memcached *memc)
{
self->item_flags= 0;
self->item_expiration= 0;
self->item_key[0]= 0;
}
-memcached_result_st *memcached_result_create(const memcached_st *memc,
+memcached_result_st *memcached_result_create(const memcached_st *shell,
memcached_result_st *ptr)
{
- WATCHPOINT_ASSERT(memc);
+ const Memcached* memc= memcached2Memcached(shell);
/* Saving malloc calls :) */
if (ptr)
#include <pthread.h>
-void memcached_set_sasl_callbacks(memcached_st *ptr,
+void memcached_set_sasl_callbacks(memcached_st *shell,
const sasl_callback_t *callbacks)
{
- ptr->sasl.callbacks= const_cast<sasl_callback_t *>(callbacks);
- ptr->sasl.is_allocated= false;
+ Memcached* self= memcached2Memcached(shell);
+ if (self)
+ {
+ self->sasl.callbacks= const_cast<sasl_callback_t *>(callbacks);
+ self->sasl.is_allocated= false;
+ }
}
-sasl_callback_t *memcached_get_sasl_callbacks(memcached_st *ptr)
+sasl_callback_t *memcached_get_sasl_callbacks(memcached_st *shell)
{
- return ptr->sasl.callbacks;
+ Memcached* self= memcached2Memcached(shell);
+ if (self)
+ {
+ return self->sasl.callbacks;
+ }
+
+ return NULL;
}
/**
return SASL_OK;
}
-memcached_return_t memcached_set_sasl_auth_data(memcached_st *ptr,
+memcached_return_t memcached_set_sasl_auth_data(memcached_st *shell,
const char *username,
const char *password)
{
+ Memcached* ptr= memcached2Memcached(shell);
if (LIBMEMCACHED_WITH_SASL_SUPPORT == 0)
{
return MEMCACHED_NOT_SUPPORTED;
return MEMCACHED_SUCCESS;
}
-memcached_return_t memcached_destroy_sasl_auth_data(memcached_st *ptr)
+memcached_return_t memcached_destroy_sasl_auth_data(memcached_st *shell)
{
if (LIBMEMCACHED_WITH_SASL_SUPPORT == 0)
{
return MEMCACHED_NOT_SUPPORTED;
}
+ Memcached* ptr= memcached2Memcached(shell);
if (ptr == NULL)
{
return MEMCACHED_INVALID_ARGUMENTS;
*/
#include <libmemcached/common.h>
-static inline void _server_init(memcached_server_st *self, memcached_st *root,
+static inline void _server_init(memcached_server_st *self, Memcached *root,
const memcached_string_t& hostname,
in_port_t port,
uint32_t weight, memcached_connection_t type)
self->hostname[hostname.size]= 0;
}
-static memcached_server_st *_server_create(memcached_server_st *self, const memcached_st *memc)
+static memcached_server_st *_server_create(memcached_server_st *self, const Memcached *memc)
{
if (self == NULL)
{
return self;
}
-memcached_server_st *__server_create_with(memcached_st *memc,
+memcached_server_st *__server_create_with(Memcached *memc,
memcached_server_st* allocated_instance,
const memcached_string_t& hostname,
const in_port_t port,
return NULL;
}
- _server_init(allocated_instance, const_cast<memcached_st *>(memc), hostname, port, weight, type);
+ _server_init(allocated_instance, const_cast<Memcached *>(memc), hostname, port, weight, type);
return allocated_instance;
}
return rc;
}
-memcached_stat_st *memcached_stat(memcached_st *self, char *args, memcached_return_t *error)
+memcached_stat_st *memcached_stat(memcached_st *shell, char *args, memcached_return_t *error)
{
+ Memcached* self= memcached2Memcached(shell);
memcached_return_t unused;
if (error == NULL)
{
We make a copy of the keys since at some point in the not so distant future
we will add support for "found" keys.
*/
-char ** memcached_stat_get_keys(memcached_st *memc,
+char ** memcached_stat_get_keys(memcached_st *shell,
memcached_stat_st *,
memcached_return_t *error)
{
+ Memcached* memc= memcached2Memcached(shell);
if (memc)
{
char **list= static_cast<char **>(libmemcached_malloc(memc, sizeof(memcached_stat_keys)));
return MEMCACHED_INVALID_ARGUMENTS;
}
-memcached_return_t memcached_stat_execute(memcached_st *memc, const char *args, memcached_stat_fn func, void *context)
+memcached_return_t memcached_stat_execute(memcached_st *shell, const char *args, memcached_stat_fn func, void *context)
{
+ Memcached* memc= memcached2Memcached(shell);
if (memcached_fatal(memcached_version(memc)))
{
return memcached_last_error(memc);
return PROTOCOL_BINARY_CMD_SET;
}
-static memcached_return_t memcached_send_binary(memcached_st *ptr,
+static memcached_return_t memcached_send_binary(Memcached *ptr,
org::libmemcached::Instance* server,
uint32_t server_key,
const char *key,
return memcached_response(server, NULL, 0, NULL);
}
-static memcached_return_t memcached_send_ascii(memcached_st *ptr,
+static memcached_return_t memcached_send_ascii(Memcached *ptr,
org::libmemcached::Instance* instance,
const char *key,
const size_t key_length,
return rc;
}
-static inline memcached_return_t memcached_send(memcached_st *ptr,
+static inline memcached_return_t memcached_send(memcached_st *shell,
const char *group_key, size_t group_key_length,
const char *key, size_t key_length,
const char *value, size_t value_length,
const uint64_t cas,
memcached_storage_action_t verb)
{
+ Memcached* ptr= memcached2Memcached(shell);
memcached_return_t rc;
if (memcached_failed(rc= initialize_query(ptr, true)))
{
self->end= self->string= NULL;
}
-memcached_string_st *memcached_string_create(memcached_st *memc, memcached_string_st *self, size_t initial_size)
+memcached_string_st *memcached_string_create(Memcached *memc, memcached_string_st *self, size_t initial_size)
{
WATCHPOINT_ASSERT(memc);
return memcached_touch_by_key(ptr, key, key_length, key, key_length, expiration);
}
-memcached_return_t memcached_touch_by_key(memcached_st *ptr,
+memcached_return_t memcached_touch_by_key(memcached_st *shell,
const char *group_key, size_t group_key_length,
const char *key, size_t key_length,
time_t expiration)
{
+ Memcached* ptr= memcached2Memcached(shell);
LIBMEMCACHED_MEMCACHED_TOUCH_START();
memcached_return_t rc;
const char *buffer;
};
-static memcached_return_t _set_verbosity(const memcached_st *,
+static memcached_return_t _set_verbosity(const Memcached *,
const memcached_server_instance_st server,
void *context)
{
libmemcached_io_vector_st *vector= (libmemcached_io_vector_st *)context;
- memcached_st local_memc;
- memcached_st *memc_ptr= memcached_create(&local_memc);
+ Memcached local_memc;
+ Memcached *memc_ptr= memcached_create(&local_memc);
memcached_return_t rc= memcached_server_add(memc_ptr, memcached_server_name(server), memcached_server_port(server));
return rc;
}
-memcached_return_t memcached_verbosity(memcached_st *ptr, uint32_t verbosity)
+memcached_return_t memcached_verbosity(memcached_st *shell, uint32_t verbosity)
{
+ Memcached* ptr= memcached2Memcached(shell);
memcached_return_t rc;
if (memcached_failed(rc= initialize_query(ptr, false)))
{
return LIBMEMCACHED_VERSION_STRING;
}
-static inline memcached_return_t memcached_version_textual(memcached_st *memc)
+static inline memcached_return_t memcached_version_textual(Memcached *memc)
{
libmemcached_io_vector_st vector[]=
{
return errors_happened ? MEMCACHED_SOME_ERRORS : MEMCACHED_SUCCESS;
}
-static inline memcached_return_t memcached_version_binary(memcached_st *memc)
+static inline memcached_return_t memcached_version_binary(Memcached *memc)
{
protocol_binary_request_version request= {};
}
}
-memcached_return_t memcached_version(memcached_st *memc)
+memcached_return_t memcached_version(memcached_st *shell)
{
+ Memcached* memc= memcached2Memcached(shell);
if (memc)
{
memcached_return_t rc;