unsigned int execute_set(memcached_st *memc, pairs_st *pairs, unsigned int number_of)
{
- memcached_return rc;
+ memcached_return_t rc;
unsigned int x;
unsigned int pairs_sent;
*/
unsigned int execute_get(memcached_st *memc, pairs_st *pairs, unsigned int number_of)
{
- memcached_return rc;
+ memcached_return_t rc;
unsigned int x;
unsigned int retrieved;
/**
* Callback function to count the number of results
*/
-static memcached_return callback_counter(memcached_st *ptr,
+static memcached_return_t callback_counter(memcached_st *ptr,
memcached_result_st *result,
void *context)
{
unsigned int number_of)
{
unsigned int retrieved= 0;
- memcached_execute_function callbacks[1]= { [0]= &callback_counter };
- memcached_return rc;
+ memcached_execute_fn callbacks[1]= { [0]= &callback_counter };
+ memcached_return_t rc;
rc= memcached_mget_execute(memc, keys, key_length,
(size_t)number_of, callbacks, &retrieved, 1);
char *string;
size_t string_length;
uint32_t flags;
- memcached_return rc;
+ memcached_return_t rc;
memcached_server_st *servers;
options_parse(argc, argv);
int main(int argc, char *argv[])
{
memcached_st *memc;
- memcached_return rc;
+ memcached_return_t rc;
memcached_server_st *servers;
options_parse(argc, argv);
static char *opt_hash= NULL;
/* Print the keys and counter how many were found */
-static memcached_return key_printer(memcached_st *ptr __attribute__((unused)),
- const char *key, size_t key_length,
- void *context __attribute__((unused)))
+static memcached_return_t key_printer(memcached_st *ptr __attribute__((unused)),
+ const char *key, size_t key_length,
+ void *context __attribute__((unused)))
{
printf("%.*s\n", (uint32_t)key_length, key);
int main(int argc, char *argv[])
{
memcached_st *memc;
- memcached_return rc;
+ memcached_return_t rc;
memcached_server_st *servers;
- memcached_dump_func callbacks[1];
+ memcached_dump_fn callbacks[1];
callbacks[0]= &key_printer;
int main(int argc, char *argv[])
{
memcached_st *memc;
- memcached_return rc;
+ memcached_return_t rc;
memcached_server_st *servers;
options_parse(argc, argv);
int main(int argc, char *argv[])
{
memcached_st *memc;
- memcached_return rc;
+ memcached_return_t rc;
memcached_server_st *servers;
options_parse(argc, argv);
int main(int argc, char *argv[])
{
- memcached_return rc;
+ memcached_return_t rc;
memcached_st *memc;
memcached_stat_st *memc_stat;
memcached_server_st *servers;
static void run_analyzer(memcached_st *memc, memcached_stat_st *memc_stat,
memcached_server_st *server_list)
{
- memcached_return rc;
+ memcached_return_t rc;
if (analyze_mode == NULL)
{
memcached_server_st *server_list)
{
unsigned int x;
- memcached_return rc;
+ memcached_return_t rc;
printf("Listing %u Server\n\n", memcached_server_count(memc));
for (x= 0; x < memcached_server_count(memc); x++)
void process_hash_option(memcached_st *memc, char *opt_hash)
{
uint64_t set;
- memcached_return rc;
+ memcached_return_t rc;
if (opt_hash == NULL)
return;
written in order to encapsulate the C<memcached_st>. It is not
recommended that you operate directly against the structure.
-Nearly all functions return a C<memcached_return> value.
+Nearly all functions return a C<memcached_return_t> value.
This value can be translated to a printable string with memcached_strerror(3).
Partitioning based on keys is supported in the library. Using the key partioning
=head2 Creating and Freeing structure
memcached_st *memc;
- memcached_return rc;
+ memcached_return_t rc;
memc= memcached_create(NULL);
...do stuff...
=head2 Fetching multiple values
- memcached_return rc;
+ memcached_return_t rc;
char *keys[]= {"fudge", "son", "food"};
size_t key_length[]= {5, 3, 4};
unsigned int x;
#include <memcached.h>
- memcached_analysis_st *memcached_analyze(memcached_st *ptr,
- memcached_stat_st *stat,
- memcached_return *error);
+ memcached_analysis_st *
+ memcached_analyze (memcached_st *ptr,
+ memcached_stat_st *stat,
+ memcached_return_t *error);
=head1 DESCRIPTION
A pointer to the allocated C<memcached_analysis_st> structure on success and
a NULL pointer on failure. You may inspect the error detail by checking the
-C<memcached_return> value.
+C<memcached_return_t> value.
Any method returning a C<memcached_analysis_st> expects you to free the
memory allocated for it.
#include <memcached.h>
- memcached_return
+ memcached_return_t
memcached_increment (memcached_st *ptr,
const char *key, size_t key_length,
unsigned int offset,
uint64_t *value);
- memcached_return
+ memcached_return_t
memcached_decrement (memcached_st *ptr,
const char *key, size_t key_length,
unsigned int offset,
uint64_t *value);
- memcached_return
+ memcached_return_t
memcached_increment_with_initial (memcached_st *ptr,
const char *key,
size_t key_length,
time_t expiration,
uint64_t *value);
- memcached_return
+ memcached_return_t
memcached_decrement_with_initial (memcached_st *ptr,
const char *key,
size_t key_length,
time_t expiration,
uint64_t *value);
- memcached_return
+ memcached_return_t
memcached_increment_by_key (memcached_st *ptr,
const char *master_key, size_t master_key_length,
const char *key, size_t key_length,
unsigned int offset,
uint64_t *value);
- memcached_return
+ memcached_return_t
memcached_decrement_by_key (memcached_st *ptr,
const char *master_key, size_t master_key_length,
const char *key, size_t key_length,
unsigned int offset,
uint64_t *value);
- memcached_return
+ memcached_return_t
memcached_increment_with_initial_by_key (memcached_st *ptr,
const char *master_key,
size_t master_key_length,
time_t expiration,
uint64_t *value);
- memcached_return
+ memcached_return_t
memcached_decrement_with_initial_by_key (memcached_st *ptr,
const char *master_key,
size_t master_key_length,
=head1 RETURN
-A value of type C<memcached_return> is returned.
+A value of type C<memcached_return_t> is returned.
On success that value will be C<MEMCACHED_SUCCESS>.
Use memcached_strerror() to translate this value to a printable string.
memcached_behavior_get (memcached_st *ptr,
memcached_behavior flag);
- memcached_return
+ memcached_return_t
memcached_behavior_set (memcached_st *ptr,
memcached_behavior flag,
uint64_t data);
#include <memcached.h>
- memcached_return
+ memcached_return_t
memcached_callback_set (memcached_st *ptr,
- memcached_callback flag,
+ memcached_callback_t flag,
void *data);
void *
memcached_callback_get (memcached_st *ptr,
- memcached_callback flag,
- memcached_return *error);
+ memcached_callback_t flag,
+ memcached_return_t *error);
=head1 DESCRIPTION
cause the object to be buffered and not sent immediatly (if this is the default behavior based on your connection setup this will happen automatically).
The prototype for this is:
-memcached_return (*memcached_trigger_key)(memcached_st *ptr, char *key, size_t key_length, memcached_result_st *result);
+memcached_return_t (*memcached_trigger_key)(memcached_st *ptr, char *key, size_t key_length, memcached_result_st *result);
=item MEMCACHED_CALLBACK_DELETE_TRIGGER
in order to make use of it.
The prototype for this is:
-typedef memcached_return (*memcached_trigger_delete_key)(memcached_st *ptr, char *key, size_t key_length);
+typedef memcached_return_t (*memcached_trigger_delete_key)(memcached_st *ptr, char *key, size_t key_length);
=back
=head1 RETURN
memcached_callback_get() return the function or structure that was provided.
-Upon error, nothing is set, null is returned, and the memcached_return
+Upon error, nothing is set, null is returned, and the memcached_return_t
argument is set to MEMCACHED_FAILURE.
memcached_callback_set() returns MEMCACHED_SUCCESS upon successful setting,
void memcached_free (memcached_st *ptr);
- memcached_st *memcached_clone(memcached_st *clone, memcached_st *source);
+ memcached_st *memcached_clone (memcached_st *destination, memcached_st *source);
=head1 DESCRIPTION
memcached_clone() is similar to memcached_create(3) but it copies the
defaults and list of servers from the source C<memcached_st>. If you pass a null as
the argument for the source to clone, it is the same as a call to memcached_create().
-If the clone argument is NULL a C<memcached_st> will be allocated for you.
-If you pass a pointer to a memory area for the clone pointer, make sure you
-memset it to 0 (unless you got the clone from a factory method in libmemcached).
+If the destination argument is NULL a C<memcached_st> will be allocated for you.
To clean up memory associated with a C<memcached_st> structure you should pass
it to memcached_free() when you are finished using it. memcached_free() is
the only way to make sure all memory is deallocated when you finish using
the structure.
+You may wish to avoid using memcached_create(3) or memcached_clone(3) with a
+stack based allocation. The most common issues related to ABI safety involve
+heap allocated structures.
+
=head1 RETURN
memcached_create() returns a pointer to the memcached_st that was created
(or initialized). On an allocation failure, it returns NULL.
memcached_clone() returns a pointer to the memcached_st that was created
-(or initialized). On an allocation failure, it returns NULL. If you pass in
-a preallocated structure it must be cleared first (aka memset()).
+(or initialized). On an allocation failure, it returns NULL.
=head1 HOME
#include <memcached.h>
- memcached_return
+ memcached_return_t
memcached_delete (memcached_st *ptr,
const char *key, size_t key_length,
time_t expiration);
- memcached_return
+ memcached_return_t
memcached_delete_by_key (memcached_st *ptr,
const char *master_key, size_t master_key_length,
const char *key, size_t key_length,
=head1 RETURN
-A value of type C<memcached_return> is returned
+A value of type C<memcached_return_t> is returned
On success that value will be C<MEMCACHED_SUCCESS>.
Use memcached_strerror() to translate this value to a printable string.
#include <memcached.h>
- memcached_return
+ memcached_return_t
memcached_dump (memcached_st *ptr,
- memcached_dump_func *function,
+ memcached_dump_fn *function,
void *context,
uint32_t number_of_callbacks);
- typedef memcached_return (*memcached_dump_func)(memcached_st *ptr,
+ typedef memcached_return_t (*memcached_dump_fn)(memcached_st *ptr,
const char *key,
size_t key_length,
void *context);
=head1 RETURN
-A value of type C<memcached_return> is returned
+A value of type C<memcached_return_t> is returned
On success that value will be C<MEMCACHED_SUCCESS>.
Use memcached_strerror() to translate this value to a printable string.
#include <memcached.h>
- memcached_return
+ memcached_return_t
memcached_flush (memcached_st *ptr,
time_t expiration);
=head1 RETURN
-A value of type C<memcached_return> is returned
+A value of type C<memcached_return_t> is returned
On success that value will be C<MEMCACHED_SUCCESS>.
Use memcached_strerror() to translate this value to a printable string.
#include <memcached.h>
- memcached_return
+ memcached_return_t
memcached_flush_buffers (memcached_st *ptr);
=head1 DESCRIPTION
memcached_flush_buffers() is used in conjunction with
MEMCACHED_BEHAVIOR_BUFFER_REQUESTS (see memcached_behavior(3)) to flush
-all buffers by sending the buffered commands to the server for processing..
+all buffers by sending the buffered commands to the server for processing.
=head1 RETURN
-A value of type C<memcached_return> is returned
+A value of type C<memcached_return_t> is returned
On success that value will be C<MEMCACHED_SUCCESS>.
Use memcached_strerror() to translate this value to a printable string.
uint32_t
memcached_generate_hash_value (const char *key,
size_t key_length,
- memcached_hash hash_algorithm);
+ memcached_hash_t hash_algorithm);
uint32_t
memcached_generate_hash (memcached_st *ptr,
the hash value that would have been generated based on the defaults
of the memcached_st structure.
+As of version 0.36 all hash methods have been placed into the library
+libhashkit(3) which is linked with libmemcached(3).
+
=head1 RETURN
A 32-bit integer which is the result of hashing the given key.
=head1 SEE ALSO
-memcached(1) libmemcached(3) memcached_behavior_set(3)
+memcached(1) libmemcached(3) memcached_behavior_set(3) libhashkit(3)
=cut
#include <memcached.h>
memcached_result_st *
- memcached_fetch_result(memcached_st *ptr,
- memcached_result_st *result,
- memcached_return *error);
-
- char *memcached_get (memcached_st *ptr,
- const char *key, size_t key_length,
- size_t *value_length,
- uint32_t *flags,
- memcached_return *error);
-
- memcached_return
- memcached_mget (memcached_st *ptr,
- const char * const *keys,
- const size_t *key_length,
+ memcached_fetch_result (memcached_st *ptr,
+ memcached_result_st *result,
+ memcached_return_t *error);
+
+ char *
+ memcached_get (memcached_st *ptr,
+ const char *key, size_t key_length,
+ size_t *value_length,
+ uint32_t *flags,
+ memcached_return_t *error);
+
+ memcached_return_t
+ memcached_mget (memcached_st *ptr,
+ const char * const *keys,
+ const size_t *key_length,
size_t number_of_keys);
char *
- memcached_get_by_key(memcached_st *ptr,
- const char *master_key, size_t master_key_length,
- const char *key, size_t key_length,
- size_t *value_length,
- uint32_t *flags,
- memcached_return *error);
-
- memcached_return
- memcached_mget_by_key(memcached_st *ptr,
- const char *master_key, size_t master_key_length,
- const char * const *keys,
- const size_t *key_length,
- size_t number_of_keys);
-
- char *memcached_fetch (memcached_st *ptr,
- char *key, size_t *key_length,
- size_t *value_length,
- uint32_t *flags,
- memcached_return *error);
-
- memcached_return
- memcached_fetch_execute(memcached_st *ptr,
- memcached_return (*callback[])(memcached_st *ptr, memcached_result_st *result, void *context),
- void *context,
- unsigned int number_of_callbacks);
-
-
- memcached_return
- memcached_mget_execute(memcached_st *ptr,
- const char * const *keys,
- const size_t *key_length,
- size_t number_of_keys,
- memcached_execute_function *callback,
- void *context,
- unsigned int number_of_callbacks);
-
- memcached_return
- memcached_mget_execute_by_key(memcached_st *ptr,
- const char *master_key,
- size_t master_key_length,
- const char * const *keys,
- const size_t *key_length,
- size_t number_of_keys,
- memcached_execute_function *callback,
- void *context,
- unsigned int number_of_callbacks);
+ memcached_get_by_key (memcached_st *ptr,
+ const char *master_key, size_t master_key_length,
+ const char *key, size_t key_length,
+ size_t *value_length,
+ uint32_t *flags,
+ memcached_return_t *error);
+
+ memcached_return_t
+ memcached_mget_by_key (memcached_st *ptr,
+ const char *master_key, size_t master_key_length,
+ const char * const *keys,
+ const size_t *key_length,
+ size_t number_of_keys);
+
+ char *
+ memcached_fetch (memcached_st *ptr,
+ char *key, size_t *key_length,
+ size_t *value_length,
+ uint32_t *flags,
+ memcached_return_t *error);
+
+ memcached_return_t
+ memcached_fetch_execute (memcached_st *ptr,
+ memcached_execute_fn *callback,
+ void *context,
+ uint32_t number_of_callbacks);
+
+
+ memcached_return_t
+ memcached_mget_execute (memcached_st *ptr,
+ const char * const *keys,
+ const size_t *key_length,
+ size_t number_of_keys,
+ memcached_execute_fn *callback,
+ void *context,
+ uint32_t number_of_callbacks);
+
+ memcached_return_t
+ memcached_mget_execute_by_key (memcached_st *ptr,
+ const char *master_key,
+ size_t master_key_length,
+ const char * const *keys,
+ const size_t *key_length,
+ size_t number_of_keys,
+ memcached_execute_fn *callback,
+ void *context,
+ uint32_t number_of_callbacks);
=head1 DESCRIPTION
three pointer variables which will give you the state of the returned
object. A uint32_t pointer to contain whatever flags you stored with the value,
a size_t pointer which will be filled with size of of the object, and a
-memcached_return pointer to hold any error. The object will be returned
+memcached_return_t pointer to hold any error. The object will be returned
upon success and NULL will be returned on failure. Any object returned by
-memcached_get() must be released by the caller application.
+memcached_get() must be released by the caller application.
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
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_fetch() is used to fetch an individual value from the server.
memcached_mget() must always be called before using this method. You
must pass in a key and its length to fetch the object. You must supply
three pointer variables which will give you the state of the returned
object. A uint32_t pointer to contain whatever flags you stored with the value,
a size_t pointer which will be filled with size of of the object, and a
-memcached_return pointer to hold any error. The object will be returned
+memcached_return_t pointer to hold any error. The object will be returned
upon success and NULL will be returned on failure. MEMCACHD_END is returned
-by the *error value when all objects that have been found are returned.
+by the *error value when all objects that have been found are returned.
The final value upon MEMCACHED_END is null. Values returned by
memcached_fetch() musted be free'ed by the caller.
-memcached_fetch_result() is used to return a memcached_result_st(3) structure
+memcached_fetch_result() is used to return a memcached_result_st(3) structure
from a memcached server. The result object is forward compatible with changes
-to the server. For more information please refer to the memcached_result_st(3)
+to the server. For more information please refer to the memcached_result_st(3)
help. This function will dynamically allocate a result structure for you
if you do not pass one to the function.
memcached_fetch_execute() is a callback function for result sets. Instead
of returning the results to you for processing, it passes each of the
result sets to the list of functions you provide. It passes to the function
-a memcached_st that can be cloned for use in the called function (it can not
+a memcached_st that can be cloned for use in the called function (it can not
be used directly). It also passes a result set which does not need to be freed.
Finally it passes a "context". This is just a pointer to a memory reference
you supply the calling function. Currently only one value is being passed
if key partitioning was used for storage.
All of the above functions are not supported when the C<MEMCACHED_BEHAVIOR_USE_UDP>
-has been set. Executing any of these functions with this behavior on will result in
+has been set. Executing any of these functions with this behavior on will result in
C<MEMCACHED_NOT_SUPPORTED> being returned or, for those functions which do not return
-a C<memcached_return>, the error function parameter will be set to
+a C<memcached_return_t>, the error function parameter will be set to
C<MEMCACHED_NOT_SUPPORTED>.
=head1 RETURN
#include <memcached.h>
- memcached_return
- memcached_set_memory_allocators(memcached_st *ptr,
- memcached_malloc_function mem_malloc,
- memcached_free_function mem_free,
- memcached_realloc_function mem_realloc,
- memcached_calloc_function mem_calloc);
-
- void memcached_get_memory_allocators(memcached_st *ptr,
- memcached_malloc_function *mem_malloc,
- memcached_free_function *mem_free,
- memcached_realloc_function *mem_realloc,
- memcached_calloc_function *mem_calloc);
-
- void *(*memcached_malloc_function)(memcached_st *ptr, const size_t size);
- void *(*memcached_realloc_function)(memcached_st *ptr, void *mem,
- const size_t size);
- void (*memcached_free_function)(memcached_st *ptr, void *mem);
- void *(*memcached_calloc_function)(memcached_st *ptr, size_t nelem,
- const size_t elsize);
+ memcached_return_t
+ memcached_set_memory_allocators (memcached_st *ptr,
+ memcached_malloc_fn mem_malloc,
+ memcached_free_fn mem_free,
+ memcached_realloc_fn mem_realloc,
+ memcached_calloc_fn mem_calloc);
+
+ void
+ memcached_get_memory_allocators (memcached_st *ptr,
+ memcached_malloc_fn *mem_malloc,
+ memcached_free_fn *mem_free,
+ memcached_realloc_fn *mem_realloc,
+ memcached_calloc_fn *mem_calloc);
+
+ void *
+ (*memcached_malloc_fn) (memcached_st *ptr, const size_t size);
+
+ void *
+ (*memcached_realloc_fn) (memcached_st *ptr, void *mem,
+ const size_t size);
+
+ void
+ (*memcached_free_fn) (memcached_st *ptr, void *mem);
+
+ void *
+ (*memcached_calloc_fn) (memcached_st *ptr, size_t nelem,
+ const size_t elsize);
=head1 DESCRIPTION
=head1 RETURN
-memcached_set_memory_allocators() return MEMCACHED_SUCCESS upon success,
+memcached_set_memory_allocators() return MEMCACHED_SUCCESS upon success,
and MEMCACHED_FAILURE if you don't pass a complete set of function pointers.
=head1 HOME
#include <libmemcached/memcached_pool.h>
- memcached_pool_st *memcached_pool_create(memcached_st* mmc, int initial, int max);
- memcached_st* memcached_pool_destroy(memcached_pool_st* pool);
+ memcached_pool_st *
+ memcached_pool_create(memcached_st* mmc, int initial, int max);
- memcached_st* memcached_pool_pop(memcached_pool_st* pool, bool block, memcached_return *rc);
- memcached_return memcached_pool_push(memcached_pool_st* pool, memcached_st *mmc);
+ memcached_st *
+ memcached_pool_destroy(memcached_pool_st* pool);
+
+ memcached_st *
+ memcached_pool_pop (memcached_pool_st* pool, bool block, memcached_return_t *rc);
+
+ memcached_return_t
+ memcached_pool_push(memcached_pool_st* pool, memcached_st *mmc);
memcached_st *memcached_create (memcached_st *ptr);
- memcached_return memcached_pool_behavior_set(memcached_pool_st *pool,
- memcached_behavior flag,
- uint64_t data)
- memcached_return memcached_pool_behavior_get(memcached_pool_st *pool,
- memcached_behavior flag,
- uint64_t *value)
+ memcached_return_t
+ memcached_pool_behavior_set(memcached_pool_st *pool,
+ memcached_behavior_t flag,
+ uint64_t data)
+
+ memcached_return_t
+ memcached_pool_behavior_get(memcached_pool_st *pool,
+ memcached_behavior_t flag,
+ uint64_t *value)
=head1 DESCRIPTION
ownership of the pointer to the caller.
memcached_pool_pop() is used to grab a connection structure from the
-connection pool. The block argument specifies if the function should
+connection pool. The block argument specifies if the function should
block and wait for a connection structure to be available if we try
to exceed the maximum size.
use it returns NULL.
memcached_pool_pop() returns a pointer to a memcached_st structure
-from the pool (or NULL if an allocation cannot be satisfied).
+from the pool (or NULL if an allocation cannot be satisfied).
memcached_pool_push() returns MEMCACHED_SUCCESS upon success.
#include <memcached.h>
- memcached_result_st *memcached_result_create(memcached_st *ptr,
- memcached_result_st *result);
+ memcached_result_st *
+ memcached_result_create (memcached_st *ptr,
+ memcached_result_st *result);
void memcached_result_free(memcached_result_st *result);
- char * memcached_result_key_value(memcached_result_st *result);
+ char * memcached_result_key_value (memcached_result_st *result);
- size_t memcached_result_key_length(memcached_result_st *result);
+ size_t memcached_result_key_length (memcached_result_st *result);
- char *memcached_result_value(memcached_result_st *ptr);
+ char *memcached_result_value (memcached_result_st *ptr);
- size_t memcached_result_length(memcached_result_st *ptr);
+ size_t memcached_result_length (memcached_result_st *ptr);
- uint32_t memcached_result_flags(memcached_result_st *result)
+ uint32_t memcached_result_flags (memcached_result_st *result)
- uint64_t memcached_result_cas(memcached_result_st *result);
+ uint64_t memcached_result_cas (memcached_result_st *result);
- memcached_return memcached_result_set_value (memcached_result_st *ptr,
- char *value, size_t length)
+ memcached_return_t
+ memcached_result_set_value (memcached_result_st *ptr,
+ char *value, size_t length)
- void memcached_result_set_flags(memcached_result_st *ptr, uint32_t flags)
+ void memcached_result_set_flags (memcached_result_st *ptr, uint32_t flags)
- void memcached_result_set_expiration(memcached_result_st *ptr, time_t)
+ void memcached_result_set_expiration (memcached_result_st *ptr, time_t)
=head1 DESCRIPTION
-libmemcached(3) can optionally return a memcached_result_st which acts as a
+libmemcached(3) can optionally return a memcached_result_st which acts as a
result object. The result objects have added benefits over the character
pointer returns in that they are forward compatible with new return items
that future memcached servers may implement (the best current example of
current result object.
memcached_result_value() returns the result value associated with the
-current result object.
+current result object.
memcached_result_length() returns the result length associated with the
-current result object.
+current result object.
memcached_result_flags() returns the flags associated with the
-current result object.
+current result object.
memcached_result_cas() returns the cas associated with the
current result object. This value will only be available if the server
void memcached_result_set_flags() takes a result structure and stores
a new value for the flags field.
-void memcached_result_set_expiration(A) takes a result structure and stores
+void memcached_result_set_expiration(A) takes a result structure and stores
a new value for the expiration field (this is only used by read through
triggers).
+You may wish to avoid using memcached_result_create(3) with a
+stack based allocation. The most common issues related to ABI safety involve
+heap allocated structures.
=head1 RETURN
Varies, see particular functions. All structures must have
-memcached_result_free() called on them for cleanup purposes. Failure to
+memcached_result_free() called on them for cleanup purposes. Failure to
do this will result in leaked memory.
=head1 HOME
memcached_server_list_append (memcached_server_st *ptr,
const char *hostname,
unsigned int port,
- memcached_return *error);
+ memcached_return_t *error);
unsigned int memcached_server_list_count (memcached_server_st *ptr);
memcached_server_st *memcached_servers_parse (const char *server_strings);
- const char *memcached_server_error(memcached_server_st *ptr);
+ const char *memcached_server_error (memcached_server_st *ptr);
- void memcached_server_error_reset(memcached_server_st *ptr);
+ void memcached_server_error_reset (memcached_server_st *ptr);
=head1 DESCRIPTION
memcached_server_list_append() adds a server to the end of a
memcached_server_st array. On error null will be returned and the
-memcached_return pointer you passed into the function will be set with the
+memcached_return_t pointer you passed into the function will be set with the
appropriate error. If the value of port is zero, it is set to the default
port of a memcached server.
memcached_server_st *
memcached_server_list (memcached_st *ptr);
- memcached_return
+ memcached_return_t
memcached_server_add (memcached_st *ptr,
const char *hostname,
- unsigned int port);
+ in_port_t port);
- memcached_return
+ memcached_return_t
memcached_server_add_udp (memcached_st *ptr,
const char *hostname,
- unsigned int port);
+ in_port_t port);
- memcached_return
+ memcached_return_t
memcached_server_add_unix_socket (memcached_st *ptr,
const char *socket);
- memcached_return
+ memcached_return_t
memcached_server_push (memcached_st *ptr,
memcached_server_st *list);
memcached_server_st *
memcached_server_by_key (memcached_st *ptr,
const char *key, size_t key_length,
- memcached_return *error);
+ memcached_return_t *error);
+
memcached_server_st *
memcached_server_get_last_disconnect (memcached_st *ptr)
#include <memcached.h>
- memcached_return
+ memcached_return_t
memcached_set (memcached_st *ptr,
const char *key, size_t key_length,
const char *value, size_t value_length,
time_t expiration,
uint32_t flags);
- memcached_return
+ memcached_return_t
memcached_add (memcached_st *ptr,
const char *key, size_t key_length,
const char *value, size_t value_length,
time_t expiration,
uint32_t flags);
- memcached_return
+ memcached_return_t
memcached_replace (memcached_st *ptr,
const char *key, size_t key_length,
const char *value, size_t value_length,
time_t expiration,
uint32_t flags);
- memcached_return
+ memcached_return_t
memcached_prepend(memcached_st *ptr,
const char *key, size_t key_length,
const char *value, size_t value_length,
time_t expiration,
uint32_t flags)
- memcached_return
+ memcached_return_t
memcached_append(memcached_st *ptr,
const char *key, size_t key_length,
const char *value, size_t value_length,
time_t expiration,
uint32_t flags)
- memcached_return
+ memcached_return_t
memcached_cas(memcached_st *ptr,
const char *key, size_t key_length,
const char *value, size_t value_length,
uint32_t flags,
uint64_t cas);
- memcached_return
+ memcached_return_t
memcached_set_by_key(memcached_st *ptr,
const char *master_key, size_t master_key_length,
const char *key, size_t key_length,
time_t expiration,
uint32_t flags);
- memcached_return
+ memcached_return_t
memcached_add_by_key(memcached_st *ptr,
const char *master_key, size_t master_key_length,
const char *key, size_t key_length,
time_t expiration,
uint32_t flags);
- memcached_return
+ memcached_return_t
memcached_replace_by_key(memcached_st *ptr,
const char *master_key, size_t master_key_length,
const char *key, size_t key_length,
time_t expiration,
uint32_t flags);
- memcached_return
+ memcached_return_t
memcached_prepend_by_key(memcached_st *ptr,
const char *master_key, size_t master_key_length,
const char *key, size_t key_length,
time_t expiration,
uint32_t flags);
- memcached_return
+ memcached_return_t
memcached_append_by_key(memcached_st *ptr,
const char *master_key, size_t master_key_length,
const char *key, size_t key_length,
time_t expiration,
uint32_t flags);
- memcached_return
+ memcached_return_t
memcached_cas_by_key(memcached_st *ptr,
const char *master_key, size_t master_key_length,
const char *key, size_t key_length,
=head1 RETURN
-All methods return a value of type C<memcached_return>.
+All methods return a value of type C<memcached_return_t>.
On success the value will be C<MEMCACHED_SUCCESS>.
Use memcached_strerror() to translate this value to a printable string.
memcached_stat_st *memcached_stat (memcached_st *ptr,
char *args,
- memcached_return *error);
-
- memcached_return memcached_stat_servername (memcached_stat_st *stat,
- char *args,
- char *hostname,
- unsigned int port);
-
- char *memcached_stat_get_value (memcached_st *ptr,
- memcached_stat_st *stat,
- char *key,
- memcached_return *error);
-
- char ** memcached_stat_get_keys (memcached_st *ptr,
- memcached_stat_st *stat,
- memcached_return *error);
+ memcached_return_t *error);
+
+ memcached_return_t memcached_stat_servername (memcached_stat_st *stat,
+ char *args,
+ const char *hostname,
+ unsigned int port);
+
+ char *
+ memcached_stat_get_value (memcached_st *ptr,
+ memcached_stat_st *stat,
+ const char *key,
+ memcached_return_t *error);
+
+ char **
+ memcached_stat_get_keys (memcached_st *ptr,
+ memcached_stat_st *stat,
+ memcached_return_t *error);
=head1 DESCRIPTION
#include <memcached.h>
- char *memcached_strerror (memcached_st *ptr,
- memcached_return rc);
+ const char *
+ memcached_strerror (memcached_st *ptr,
+ memcached_return_t rc);
=head1 DESCRIPTION
-memcached_strerror() takes a C<memcached_return> value and returns a string
+memcached_strerror() takes a C<memcached_return_t> value and returns a string
describing the error.
This string must not be modified by the application.
-C<memcached_return> values are returned from nearly all libmemcached(3) functions.
+C<memcached_return_t> values are returned from nearly all libmemcached(3) functions.
-C<memcached_return> values are of an enum type so that you can set up responses
+C<memcached_return_t> values are of an enum type so that you can set up responses
with switch/case and know that you are capturing all possible return values.
=head1 RETURN
-memcached_strerror() returns a string describing a C<memcached_return> value.
+memcached_strerror() returns a string describing a C<memcached_return_t> value.
=head1 HOME
#include <memcached.h>
- void *memcached_get_user_data(memcached_st *ptr);
- void *memcached_set_user_data(memcached_st *ptr, void *data);
+ void *memcached_get_user_data (memcached_st *ptr);
+
+ void *memcached_set_user_data (memcached_st *ptr, void *data);
=head1 DESCRIPTION
#include <memcached.h>
- memcached_return memcached_verbosity (memcached_st *ptr,
- unsigned int verbosity);
+ memcached_return_t
+ memcached_verbosity (memcached_st *ptr,
+ unsigned int verbosity);
=head1 DESCRIPTION
=head1 RETURN
-A value of type C<memcached_return> is returned
+A value of type C<memcached_return_t> is returned
On success that value will be C<MEMCACHED_SUCCESS>.
Use memcached_strerror() to translate this value to a printable string.
#include <memcached.h>
const char *
- memcached_lib_version(void)
+ memcached_lib_version (void)
- memcached_return
- memcached_version(memcached_st *ptr)
+ memcached_return_t
+ memcached_version (memcached_st *ptr)
=head1 DESCRIPTION
A string with the version of libmemcached driver is returned from
memcached_lib_version()
-A value of type C<memcached_return> is returned from memcached_version()
+A value of type C<memcached_return_t> is returned from memcached_version()
On success that value will be C<MEMCACHED_SUCCESS>. If called with the
C<MEMCACHED_BEHAVIOR_USE_UDP> behavior set, the value C<MEMCACHED_NOT_SUPPORTED>
will be returned. Use memcached_strerror() to translate this value to
const void* val,
uint32_t vallen,
uint64_t cas,
- uint64_t *result_cas) {
+ uint64_t *result_cas)
+{
(void)cookie;
protocol_binary_response_status rval= PROTOCOL_BINARY_RESPONSE_SUCCESS;
pkginclude_HEADERS= memcached.h \
memcached.hpp \
exception.hpp \
+ memcached_behavior.h \
memcached_configure.h \
memcached_constants.h \
memcached_get.h \
uint32_t jenkins_hash(const void *key, size_t length, uint32_t initval);
LIBMEMCACHED_LOCAL
-memcached_return memcached_connect(memcached_server_st *ptr);
+memcached_return_t memcached_connect(memcached_server_st *ptr);
LIBMEMCACHED_LOCAL
-memcached_return memcached_response(memcached_server_st *ptr,
- char *buffer, size_t buffer_length,
- memcached_result_st *result);
+memcached_return_t memcached_response(memcached_server_st *ptr,
+ char *buffer, size_t buffer_length,
+ memcached_result_st *result);
LIBMEMCACHED_LOCAL
void memcached_quit_server(memcached_server_st *ptr, uint8_t io_death);
#define memcached_server_response_reset(A) (A)->cursor_active=0
LIBMEMCACHED_LOCAL
-memcached_return memcached_do(memcached_server_st *ptr, const void *commmand,
- size_t command_length, uint8_t with_flush);
+memcached_return_t memcached_do(memcached_server_st *ptr, const void *commmand,
+ size_t command_length, uint8_t with_flush);
LIBMEMCACHED_LOCAL
-memcached_return value_fetch(memcached_server_st *ptr,
- char *buffer,
- memcached_result_st *result);
+memcached_return_t value_fetch(memcached_server_st *ptr,
+ char *buffer,
+ memcached_result_st *result);
LIBMEMCACHED_LOCAL
void server_list_free(memcached_st *ptr, memcached_server_st *servers);
LIBMEMCACHED_LOCAL
-memcached_return memcached_key_test(const char * const *keys,
- const size_t *key_length,
- size_t number_of_keys);
+memcached_return_t memcached_key_test(const char * const *keys,
+ const size_t *key_length,
+ size_t number_of_keys);
LIBMEMCACHED_LOCAL
uint32_t generate_hash(memcached_st *ptr, const char *key, size_t key_length);
LIBMEMCACHED_LOCAL
-memcached_return memcached_purge(memcached_server_st *ptr);
+memcached_return_t memcached_purge(memcached_server_st *ptr);
-static inline memcached_return memcached_validate_key_length(size_t key_length,
- bool binary) {
+static inline memcached_return_t memcached_validate_key_length(size_t key_length, bool binary)
+{
unlikely (key_length == 0)
return MEMCACHED_BAD_KEY_PROVIDED;
*/
memcached_st *memcached_clone(memcached_st *clone, memcached_st *source)
{
- memcached_return rc= MEMCACHED_SUCCESS;
+ memcached_return_t rc= MEMCACHED_SUCCESS;
memcached_st *new_clone;
if (source == NULL)
-/*
+/* LibMemcached
+ * Copyright (C) 2006-2009 Brian Aker
+ * All rights reserved.
+ *
+ * Use and distribution licensed under the BSD license. See
+ * the COPYING file in the parent directory for full text.
+ *
* Summary: interface for memcached server
* Description: main include file for libmemcached
*
- * Copy: See Copyright for the status of this software.
- *
- * Author: Brian Aker
*/
#ifndef __MEMCACHED_H__
#include <libmemcached/memcached_configure.h>
#include <libmemcached/memcached_constants.h>
#include <libmemcached/memcached_types.h>
+#include <libmemcached/memcached_behavior.h>
#include <libmemcached/memcached_get.h>
#include <libmemcached/memcached_server.h>
#include <libmemcached/memcached_string.h>
void *user_data;
time_t next_distribution_rebuild;
size_t prefix_key_length;
- memcached_hash hash_continuum;
+ memcached_hash_t hash_continuum;
memcached_result_st result;
memcached_continuum_item_st *continuum;
- memcached_clone_func on_clone;
- memcached_cleanup_func on_cleanup;
- memcached_free_function call_free;
- memcached_malloc_function call_malloc;
- memcached_realloc_function call_realloc;
- memcached_calloc_function call_calloc;
- memcached_trigger_key get_key_failure;
- memcached_trigger_delete_key delete_trigger;
+ memcached_clone_fn on_clone;
+ memcached_cleanup_fn on_cleanup;
+ memcached_free_fn call_free;
+ memcached_malloc_fn call_malloc;
+ memcached_realloc_fn call_realloc;
+ memcached_calloc_fn call_calloc;
+ memcached_trigger_key_fn get_key_failure;
+ memcached_trigger_delete_key_fn delete_trigger;
char prefix_key[MEMCACHED_PREFIX_KEY_MAX_SIZE];
uint32_t number_of_replicas;
memcached_callback_st *callbacks;
};
LIBMEMCACHED_API
-memcached_return memcached_version(memcached_st *ptr);
+memcached_return_t memcached_version(memcached_st *ptr);
/* Public API */
memcached_st *memcached_clone(memcached_st *clone, memcached_st *ptr);
LIBMEMCACHED_API
-memcached_return memcached_delete(memcached_st *ptr, const char *key, size_t key_length,
+memcached_return_t memcached_delete(memcached_st *ptr, const char *key, size_t key_length,
time_t expiration);
LIBMEMCACHED_API
-memcached_return memcached_increment(memcached_st *ptr,
+memcached_return_t memcached_increment(memcached_st *ptr,
const char *key, size_t key_length,
uint32_t offset,
uint64_t *value);
LIBMEMCACHED_API
-memcached_return memcached_decrement(memcached_st *ptr,
+memcached_return_t memcached_decrement(memcached_st *ptr,
const char *key, size_t key_length,
uint32_t offset,
uint64_t *value);
LIBMEMCACHED_API
-memcached_return memcached_increment_by_key(memcached_st *ptr,
+memcached_return_t memcached_increment_by_key(memcached_st *ptr,
const char *master_key, size_t master_key_length,
const char *key, size_t key_length,
uint64_t offset,
uint64_t *value);
LIBMEMCACHED_API
-memcached_return memcached_decrement_by_key(memcached_st *ptr,
+memcached_return_t memcached_decrement_by_key(memcached_st *ptr,
const char *master_key, size_t master_key_length,
const char *key, size_t key_length,
uint64_t offset,
uint64_t *value);
LIBMEMCACHED_API
-memcached_return memcached_increment_with_initial(memcached_st *ptr,
+memcached_return_t memcached_increment_with_initial(memcached_st *ptr,
const char *key,
size_t key_length,
uint64_t offset,
time_t expiration,
uint64_t *value);
LIBMEMCACHED_API
-memcached_return memcached_decrement_with_initial(memcached_st *ptr,
+memcached_return_t memcached_decrement_with_initial(memcached_st *ptr,
const char *key,
size_t key_length,
uint64_t offset,
time_t expiration,
uint64_t *value);
LIBMEMCACHED_API
-memcached_return memcached_increment_with_initial_by_key(memcached_st *ptr,
+memcached_return_t memcached_increment_with_initial_by_key(memcached_st *ptr,
const char *master_key,
size_t master_key_length,
const char *key,
time_t expiration,
uint64_t *value);
LIBMEMCACHED_API
-memcached_return memcached_decrement_with_initial_by_key(memcached_st *ptr,
+memcached_return_t memcached_decrement_with_initial_by_key(memcached_st *ptr,
const char *master_key,
size_t master_key_length,
const char *key,
uint64_t *value);
LIBMEMCACHED_API
void memcached_stat_free(memcached_st *, memcached_stat_st *);
+
LIBMEMCACHED_API
-memcached_stat_st *memcached_stat(memcached_st *ptr, char *args, memcached_return *error);
+memcached_stat_st *memcached_stat(memcached_st *ptr, char *args, memcached_return_t *error);
+
LIBMEMCACHED_API
-memcached_return memcached_stat_servername(memcached_stat_st *memc_stat, char *args,
- char *hostname, unsigned int port);
+memcached_return_t memcached_stat_servername(memcached_stat_st *memc_stat, char *args,
+ const char *hostname, in_port_t port);
+
LIBMEMCACHED_API
-memcached_return memcached_flush(memcached_st *ptr, time_t expiration);
+memcached_return_t memcached_flush(memcached_st *ptr, time_t expiration);
+
LIBMEMCACHED_API
-memcached_return memcached_verbosity(memcached_st *ptr, unsigned int verbosity);
+memcached_return_t memcached_verbosity(memcached_st *ptr, unsigned int verbosity);
+
LIBMEMCACHED_API
void memcached_quit(memcached_st *ptr);
+
LIBMEMCACHED_API
-const char *memcached_strerror(memcached_st *ptr, memcached_return rc);
-LIBMEMCACHED_API
-memcached_return memcached_behavior_set(memcached_st *ptr, memcached_behavior flag, uint64_t data);
-LIBMEMCACHED_API
-uint64_t memcached_behavior_get(memcached_st *ptr, memcached_behavior flag);
+const char *memcached_strerror(memcached_st *ptr, memcached_return_t rc);
/* The two public hash bits */
LIBMEMCACHED_API
-uint32_t memcached_generate_hash_value(const char *key, size_t key_length, memcached_hash hash_algorithm);
+uint32_t memcached_generate_hash_value(const char *key, size_t key_length, memcached_hash_t hash_algorithm);
+
LIBMEMCACHED_API
uint32_t memcached_generate_hash(memcached_st *ptr, const char *key, size_t key_length);
LIBMEMCACHED_API
-memcached_return memcached_flush_buffers(memcached_st *mem);
+memcached_return_t memcached_flush_buffers(memcached_st *mem);
/* Server Public functions */
LIBMEMCACHED_API
-memcached_return memcached_server_add_udp(memcached_st *ptr,
+memcached_return_t memcached_server_add_udp(memcached_st *ptr,
const char *hostname,
- unsigned int port);
+ in_port_t port);
LIBMEMCACHED_API
-memcached_return memcached_server_add_unix_socket(memcached_st *ptr,
+memcached_return_t memcached_server_add_unix_socket(memcached_st *ptr,
const char *filename);
LIBMEMCACHED_API
-memcached_return memcached_server_add(memcached_st *ptr, const char *hostname,
- unsigned int port);
+memcached_return_t memcached_server_add(memcached_st *ptr,
+ const char *hostname, in_port_t port);
LIBMEMCACHED_API
-memcached_return memcached_server_add_udp_with_weight(memcached_st *ptr,
+memcached_return_t memcached_server_add_udp_with_weight(memcached_st *ptr,
const char *hostname,
- unsigned int port,
+ in_port_t port,
uint32_t weight);
LIBMEMCACHED_API
-memcached_return memcached_server_add_unix_socket_with_weight(memcached_st *ptr,
+memcached_return_t memcached_server_add_unix_socket_with_weight(memcached_st *ptr,
const char *filename,
uint32_t weight);
LIBMEMCACHED_API
-memcached_return memcached_server_add_with_weight(memcached_st *ptr, const char *hostname,
- unsigned int port,
+memcached_return_t memcached_server_add_with_weight(memcached_st *ptr, const char *hostname,
+ in_port_t port,
uint32_t weight);
LIBMEMCACHED_API
void memcached_server_list_free(memcached_server_st *ptr);
+
LIBMEMCACHED_API
-memcached_return memcached_server_push(memcached_st *ptr, memcached_server_st *list);
+memcached_return_t memcached_server_push(memcached_st *ptr, memcached_server_st *list);
LIBMEMCACHED_API
memcached_server_st *memcached_server_list_append(memcached_server_st *ptr,
const char *hostname,
- unsigned int port,
- memcached_return *error);
+ in_port_t port,
+ memcached_return_t *error);
LIBMEMCACHED_API
memcached_server_st *memcached_server_list_append_with_weight(memcached_server_st *ptr,
const char *hostname,
- unsigned int port,
+ in_port_t port,
uint32_t weight,
- memcached_return *error);
+ memcached_return_t *error);
LIBMEMCACHED_API
unsigned int memcached_server_list_count(memcached_server_st *ptr);
+
LIBMEMCACHED_API
memcached_server_st *memcached_servers_parse(const char *server_strings);
LIBMEMCACHED_API
char *memcached_stat_get_value(memcached_st *ptr, memcached_stat_st *memc_stat,
- const char *key, memcached_return *error);
+ const char *key, memcached_return_t *error);
LIBMEMCACHED_API
char ** memcached_stat_get_keys(memcached_st *ptr, memcached_stat_st *memc_stat,
- memcached_return *error);
+ memcached_return_t *error);
LIBMEMCACHED_API
-memcached_return memcached_delete_by_key(memcached_st *ptr,
- const char *master_key, size_t master_key_length,
- const char *key, size_t key_length,
- time_t expiration);
+memcached_return_t memcached_delete_by_key(memcached_st *ptr,
+ const char *master_key, size_t master_key_length,
+ const char *key, size_t key_length,
+ time_t expiration);
LIBMEMCACHED_API
-memcached_return memcached_fetch_execute(memcached_st *ptr,
- memcached_execute_function *callback,
- void *context,
- unsigned int number_of_callbacks);
+memcached_return_t memcached_fetch_execute(memcached_st *ptr,
+ memcached_execute_fn *callback,
+ void *context,
+ unsigned int number_of_callbacks);
LIBMEMCACHED_API
-memcached_return memcached_callback_set(memcached_st *ptr,
- memcached_callback flag,
- void *data);
+memcached_return_t memcached_callback_set(memcached_st *ptr,
+ memcached_callback_t flag,
+ void *data);
LIBMEMCACHED_API
void *memcached_callback_get(memcached_st *ptr,
- memcached_callback flag,
- memcached_return *error);
+ memcached_callback_t flag,
+ memcached_return_t *error);
LIBMEMCACHED_API
-memcached_return memcached_dump(memcached_st *ptr, memcached_dump_func *function, void *context, uint32_t number_of_callbacks);
+memcached_return_t memcached_dump(memcached_st *ptr, memcached_dump_fn *function, void *context, uint32_t number_of_callbacks);
LIBMEMCACHED_API
-memcached_return memcached_set_memory_allocators(memcached_st *ptr,
- memcached_malloc_function mem_malloc,
- memcached_free_function mem_free,
- memcached_realloc_function mem_realloc,
- memcached_calloc_function mem_calloc);
+memcached_return_t memcached_set_memory_allocators(memcached_st *ptr,
+ memcached_malloc_fn mem_malloc,
+ memcached_free_fn mem_free,
+ memcached_realloc_fn mem_realloc,
+ memcached_calloc_fn mem_calloc);
LIBMEMCACHED_API
void memcached_get_memory_allocators(memcached_st *ptr,
- memcached_malloc_function *mem_malloc,
- memcached_free_function *mem_free,
- memcached_realloc_function *mem_realloc,
- memcached_calloc_function *mem_calloc);
+ memcached_malloc_fn *mem_malloc,
+ memcached_free_fn *mem_free,
+ memcached_realloc_fn *mem_realloc,
+ memcached_calloc_fn *mem_calloc);
LIBMEMCACHED_API
void *memcached_get_user_data(memcached_st *ptr);
void *memcached_set_user_data(memcached_st *ptr, void *data);
LIBMEMCACHED_LOCAL
-memcached_return run_distribution(memcached_st *ptr);
+memcached_return_t run_distribution(memcached_st *ptr);
#define memcached_is_allocated(__object) ((__object)->options.is_allocated)
#define memcached_is_initialized(__object) ((__object)->options.is_initialized)
{
public:
- Memcache()
- :
+ Memcache()
+ :
servers_list(),
memc(),
servers(NULL),
memcached_server_push(&memc, servers);
}
- Memcache(memcached_st *clone)
- :
+ Memcache(memcached_st *clone)
+ :
servers_list(),
memc(),
servers(NULL),
/**
* Return an error string for the given return structure.
*
- * @param[in] rc a memcached_return structure
+ * @param[in] rc a memcached_return_t structure
* @return error string corresponding to given return code in the library.
*/
- const std::string getError(memcached_return rc) const
+ const std::string getError(memcached_return_t rc) const
{
/* first parameter to strerror is unused */
return memcached_strerror(NULL, rc);
}
- bool setBehavior(memcached_behavior flag, uint64_t data) {
- memcached_return rc;
+ bool setBehavior(memcached_behavior_t flag, uint64_t data)
+ {
+ memcached_return_t rc;
rc= memcached_behavior_set(&memc, flag, data);
return (rc == MEMCACHED_SUCCESS);
}
- uint64_t getBehavior(memcached_behavior flag) {
+ uint64_t getBehavior(memcached_behavior_t flag) {
return memcached_behavior_get(&memc, flag);
}
*/
bool addServer(const std::string &server_name, unsigned int port)
{
- memcached_return rc;
+ memcached_return_t rc;
std::ostringstream strstm;
servers_list.append(",");
servers_list.append(server_name);
strstm << port;
tmp_str.append(strstm.str());
memcached_server_st *server= memcached_servers_parse(tmp_str.c_str());
- memcached_return rc= memcached_server_remove(server);
+ memcached_return_t rc= memcached_server_remove(server);
return (rc == MEMCACHED_SUCCESS);
}
* @param[out] ret_val store returned object in this vector
* @return a memcached return structure
*/
- memcached_return fetch(std::string &key,
+ memcached_return_t fetch(std::string &key,
std::vector<char> &ret_val)
{
char ret_key[MEMCACHED_MAX_KEY];
size_t value_length= 0;
size_t key_length= 0;
- memcached_return rc;
+ memcached_return_t rc;
uint32_t flags= 0;
char *value= memcached_fetch(&memc, ret_key, &key_length,
&value_length, &flags, &rc);
* this vector
* @return true on success; false otherwise
*/
- bool get(const std::string &key,
+ bool get(const std::string &key,
std::vector<char> &ret_val) throw (Error)
{
uint32_t flags= 0;
- memcached_return rc;
+ memcached_return_t rc;
size_t value_length= 0;
if (key.empty())
/**
* Fetches an individual from a server which is specified by
* the master_key parameter that is used for determining which
- * server an object was stored in if key partitioning was
+ * server an object was stored in if key partitioning was
* used for storage.
*
* @param[in] master_key key that specifies server object is stored on
* this vector
* @return true on success; false otherwise
*/
- bool getByKey(const std::string &master_key,
- const std::string &key,
+ bool getByKey(const std::string &master_key,
+ const std::string &key,
std::vector<char> &ret_val) throw(Error)
{
uint32_t flags= 0;
- memcached_return rc;
+ memcached_return_t rc;
size_t value_length= 0;
if (master_key.empty() || key.empty())
}
/*
- * If the std::vector of keys is empty then we cannot
+ * If the std::vector of keys is empty then we cannot
* call memcached_mget as we will get undefined behavior.
*/
if (! real_keys.empty())
{
- memcached_return rc= memcached_mget(&memc, &real_keys[0], &key_len[0],
+ memcached_return_t rc= memcached_mget(&memc, &real_keys[0], &key_len[0],
real_keys.size());
return (rc == MEMCACHED_SUCCESS);
}
{
throw(Error("the key or value supplied is empty!", false));
}
- memcached_return rc= memcached_set(&memc,
+ memcached_return_t rc= memcached_set(&memc,
key.c_str(), key.length(),
&value[0], value.size(),
expiration, flags);
* @param[in] flags flags to store with the object
* @return true on succcess; false otherwise
*/
- bool setByKey(const std::string &master_key,
- const std::string &key,
+ bool setByKey(const std::string &master_key,
+ const std::string &key,
const std::vector<char> &value,
time_t expiration,
uint32_t flags) throw(Error)
{
throw(Error("the key or value supplied is empty!", false));
}
- memcached_return rc= memcached_set_by_key(&memc, master_key.c_str(),
+ memcached_return_t rc= memcached_set_by_key(&memc, master_key.c_str(),
master_key.length(),
key.c_str(), key.length(),
&value[0], value.size(),
{
throw(Error("the key supplied is empty!", false));
}
- memcached_return rc= memcached_increment(&memc, key.c_str(), key.length(),
+ memcached_return_t rc= memcached_increment(&memc, key.c_str(), key.length(),
offset, value);
return (rc == MEMCACHED_SUCCESS);
}
{
throw(Error("the key supplied is empty!", false));
}
- memcached_return rc= memcached_decrement(&memc, key.c_str(),
+ memcached_return_t rc= memcached_decrement(&memc, key.c_str(),
key.length(),
offset, value);
return (rc == MEMCACHED_SUCCESS);
{
throw(Error("the key or value supplied is empty!", false));
}
- memcached_return rc= memcached_add(&memc, key.c_str(), key.length(),
+ memcached_return_t rc= memcached_add(&memc, key.c_str(), key.length(),
&value[0], value.size(), 0, 0);
return (rc == MEMCACHED_SUCCESS);
}
* @param[in] value of object to add
* @return true on success; false otherwise
*/
- bool addByKey(const std::string &master_key,
- const std::string &key,
+ bool addByKey(const std::string &master_key,
+ const std::string &key,
const std::vector<char> &value) throw(Error)
{
if (master_key.empty() ||
- key.empty() ||
+ key.empty() ||
value.empty())
{
throw(Error("the master key or key supplied is empty!", false));
}
- memcached_return rc= memcached_add_by_key(&memc,
+ memcached_return_t rc= memcached_add_by_key(&memc,
master_key.c_str(),
master_key.length(),
key.c_str(),
key.length(),
- &value[0],
+ &value[0],
value.size(),
0, 0);
return (rc == MEMCACHED_SUCCESS);
{
throw(Error("the key or value supplied is empty!", false));
}
- memcached_return rc= memcached_replace(&memc, key.c_str(), key.length(),
+ memcached_return_t rc= memcached_replace(&memc, key.c_str(), key.length(),
&value[0], value.size(),
0, 0);
return (rc == MEMCACHED_SUCCESS);
* @param[in[ value value to replace object with
* @return true on success; false otherwise
*/
- bool replaceByKey(const std::string &master_key,
- const std::string &key,
+ bool replaceByKey(const std::string &master_key,
+ const std::string &key,
const std::vector<char> &value)
{
if (master_key.empty() ||
{
throw(Error("the master key or key supplied is empty!", false));
}
- memcached_return rc= memcached_replace_by_key(&memc,
- master_key.c_str(),
+ memcached_return_t rc= memcached_replace_by_key(&memc,
+ master_key.c_str(),
master_key.length(),
- key.c_str(),
+ key.c_str(),
key.length(),
- &value[0],
- value.size(),
+ &value[0],
+ value.size(),
0, 0);
return (rc == MEMCACHED_SUCCESS);
}
{
throw(Error("the key or value supplied is empty!", false));
}
- memcached_return rc= memcached_prepend(&memc, key.c_str(), key.length(),
+ memcached_return_t rc= memcached_prepend(&memc, key.c_str(), key.length(),
&value[0], value.size(), 0, 0);
return (rc == MEMCACHED_SUCCESS);
}
* @param[in] value data to prepend to object's value
* @return true on success; false otherwise
*/
- bool prependByKey(const std::string &master_key,
- const std::string &key,
+ bool prependByKey(const std::string &master_key,
+ const std::string &key,
const std::vector<char> &value)
throw(Error)
{
{
throw(Error("the master key or key supplied is empty!", false));
}
- memcached_return rc= memcached_prepend_by_key(&memc,
+ memcached_return_t rc= memcached_prepend_by_key(&memc,
master_key.c_str(),
master_key.length(),
key.c_str(),
{
throw(Error("the key or value supplied is empty!", false));
}
- memcached_return rc= memcached_append(&memc,
+ memcached_return_t rc= memcached_append(&memc,
key.c_str(),
key.length(),
&value[0],
{
throw(Error("the master key or key supplied is empty!", false));
}
- memcached_return rc= memcached_append_by_key(&memc,
- master_key.c_str(),
+ memcached_return_t rc= memcached_append_by_key(&memc,
+ master_key.c_str(),
master_key.length(),
- key.c_str(),
+ key.c_str(),
key.length(),
- &value[0],
- value.size(),
+ &value[0],
+ value.size(),
0, 0);
return (rc == MEMCACHED_SUCCESS);
}
* @param[in] value value to store for object in server
* @param[in] cas_arg "cas" value
*/
- bool cas(const std::string &key,
- const std::vector<char> &value,
+ bool cas(const std::string &key,
+ const std::vector<char> &value,
uint64_t cas_arg) throw(Error)
{
if (key.empty() || value.empty())
{
throw(Error("the key or value supplied is empty!", false));
}
- memcached_return rc= memcached_cas(&memc, key.c_str(), key.length(),
- &value[0], value.size(),
+ memcached_return_t rc= memcached_cas(&memc, key.c_str(), key.length(),
+ &value[0], value.size(),
0, 0, cas_arg);
return (rc == MEMCACHED_SUCCESS);
}
* @param[in] value value to store for object in server
* @param[in] cas_arg "cas" value
*/
- bool casByKey(const std::string &master_key,
- const std::string &key,
- const std::vector<char> &value,
+ bool casByKey(const std::string &master_key,
+ const std::string &key,
+ const std::vector<char> &value,
uint64_t cas_arg) throw(Error)
{
if (master_key.empty() ||
{
throw(Error("the master key, key or value supplied is empty!", false));
}
- memcached_return rc= memcached_cas_by_key(&memc,
- master_key.c_str(),
+ memcached_return_t rc= memcached_cas_by_key(&memc,
+ master_key.c_str(),
master_key.length(),
- key.c_str(),
+ key.c_str(),
key.length(),
- &value[0],
+ &value[0],
value.size(),
0, 0, cas_arg);
return (rc == MEMCACHED_SUCCESS);
{
throw(Error("the key supplied is empty!", false));
}
- memcached_return rc= memcached_delete(&memc, key.c_str(), key.length(), 0);
+ memcached_return_t rc= memcached_delete(&memc, key.c_str(), key.length(), 0);
return (rc == MEMCACHED_SUCCESS);
}
{
throw(Error("the key supplied is empty!", false));
}
- memcached_return rc= memcached_delete(&memc,
+ memcached_return_t rc= memcached_delete(&memc,
key.c_str(),
key.length(),
expiration);
}
/**
- * Delete an object from the server specified by the key given.
+ * Delete an object from the server specified by the key given.
*
* @param[in] master_key specifies server to remove object from
* @param[in] key key of object to delete
{
throw(Error("the master key or key supplied is empty!", false));
}
- memcached_return rc= memcached_delete_by_key(&memc,
+ memcached_return_t rc= memcached_delete_by_key(&memc,
master_key.c_str(),
master_key.length(),
key.c_str(),
}
/**
- * Delete an object from the server specified by the key given.
+ * Delete an object from the server specified by the key given.
*
* @param[in] master_key specifies server to remove object from
* @param[in] key key of object to delete
* @param[in] expiration time to delete the object after
* @return true on success; false otherwise
*/
- bool removeByKey(const std::string &master_key,
+ bool removeByKey(const std::string &master_key,
const std::string &key,
time_t expiration) throw(Error)
{
{
throw(Error("the master key or key supplied is empty!", false));
}
- memcached_return rc= memcached_delete_by_key(&memc,
- master_key.c_str(),
+ memcached_return_t rc= memcached_delete_by_key(&memc,
+ master_key.c_str(),
master_key.length(),
- key.c_str(),
- key.length(),
+ key.c_str(),
+ key.length(),
expiration);
return (rc == MEMCACHED_SUCCESS);
}
*/
bool flush(time_t expiration)
{
- memcached_return rc= memcached_flush(&memc, expiration);
+ memcached_return_t rc= memcached_flush(&memc, expiration);
return (rc == MEMCACHED_SUCCESS);
}
* @param[in] num_of_callbacks number of callback functions
* @return true on success; false otherwise
*/
- bool fetchExecute(memcached_execute_function *callback,
+ bool fetchExecute(memcached_execute_fn *callback,
void *context,
- unsigned int num_of_callbacks)
+ uint32_t num_of_callbacks)
{
- memcached_return rc= memcached_fetch_execute(&memc,
+ memcached_return_t rc= memcached_fetch_execute(&memc,
callback,
context,
num_of_callbacks);
bool getStats(std::map< std::string, std::map<std::string, std::string> >
&stats_map)
{
- memcached_return rc;
+ memcached_return_t rc;
memcached_stat_st *stats= memcached_stat(&memc, NULL, &rc);
if (rc != MEMCACHED_SUCCESS &&
server_stats[*ptr]= value;
free(value);
}
-
+
stats_map[server_name]= server_stats;
free(list);
}
return calloc(nelem, size);
}
-memcached_return memcached_set_memory_allocators(memcached_st *ptr,
- memcached_malloc_function mem_malloc,
- memcached_free_function mem_free,
- memcached_realloc_function mem_realloc,
- memcached_calloc_function mem_calloc)
+memcached_return_t memcached_set_memory_allocators(memcached_st *ptr,
+ memcached_malloc_fn mem_malloc,
+ memcached_free_fn mem_free,
+ memcached_realloc_fn mem_realloc,
+ memcached_calloc_fn mem_calloc)
{
/* All should be set, or none should be set */
if (mem_malloc == NULL && mem_free == NULL && mem_realloc == NULL && mem_calloc == NULL)
}
void memcached_get_memory_allocators(memcached_st *ptr,
- memcached_malloc_function *mem_malloc,
- memcached_free_function *mem_free,
- memcached_realloc_function *mem_realloc,
- memcached_calloc_function *mem_calloc)
+ memcached_malloc_fn *mem_malloc,
+ memcached_free_fn *mem_free,
+ memcached_realloc_fn *mem_realloc,
+ memcached_calloc_fn *mem_calloc)
{
*mem_malloc= ptr->call_malloc;
*mem_free= ptr->call_free;
memcached_analysis_st *memcached_analyze(memcached_st *memc,
memcached_stat_st *memc_stat,
- memcached_return *error)
+ memcached_return_t *error)
{
uint64_t total_items= 0, total_bytes= 0;
uint64_t total_get_cmds= 0, total_get_hits= 0;
+/* LibMemcached
+ * Copyright (C) 2006-2009 Brian Aker
+ * All rights reserved.
+ *
+ * Use and distribution licensed under the BSD license. See
+ * the COPYING file in the parent directory for full text.
+ *
+ * Summary: Methods for adding or decrementing values from an object in memcached
+ *
+ */
+
#include "common.h"
-static memcached_return memcached_auto(memcached_st *ptr,
- const char *verb,
- const char *master_key, size_t master_key_length,
- const char *key, size_t key_length,
- uint64_t offset,
- uint64_t *value)
+static memcached_return_t memcached_auto(memcached_st *ptr,
+ const char *verb,
+ const char *master_key, size_t master_key_length,
+ const char *key, size_t key_length,
+ uint64_t offset,
+ uint64_t *value)
{
size_t send_length;
- memcached_return rc;
+ memcached_return_t rc;
char buffer[MEMCACHED_DEFAULT_COMMAND_SIZE];
unsigned int server_key;
bool no_reply= ptr->flags.no_reply;
return rc;
}
-static memcached_return binary_incr_decr(memcached_st *ptr, uint8_t cmd,
- const char *master_key, size_t master_key_length,
- const char *key, size_t key_length,
- uint64_t offset, uint64_t initial,
- uint32_t expiration,
- uint64_t *value)
+static memcached_return_t binary_incr_decr(memcached_st *ptr, uint8_t cmd,
+ const char *master_key, size_t master_key_length,
+ const char *key, size_t key_length,
+ uint64_t offset, uint64_t initial,
+ uint32_t expiration,
+ uint64_t *value)
{
unsigned int server_key;
bool no_reply= ptr->flags.no_reply;
return memcached_response(&ptr->hosts[server_key], (char*)value, sizeof(*value), NULL);
}
-memcached_return memcached_increment(memcached_st *ptr,
- const char *key, size_t key_length,
- uint32_t offset,
- uint64_t *value)
+memcached_return_t memcached_increment(memcached_st *ptr,
+ const char *key, size_t key_length,
+ uint32_t offset,
+ uint64_t *value)
{
return memcached_increment_by_key(ptr, key, key_length, key, key_length, offset, value);
}
-memcached_return memcached_decrement(memcached_st *ptr,
- const char *key, size_t key_length,
- uint32_t offset,
- uint64_t *value)
+memcached_return_t memcached_decrement(memcached_st *ptr,
+ const char *key, size_t key_length,
+ uint32_t offset,
+ uint64_t *value)
{
return memcached_decrement_by_key(ptr, key, key_length, key, key_length, offset, value);
}
-memcached_return memcached_increment_by_key(memcached_st *ptr,
- const char *master_key, size_t master_key_length,
- const char *key, size_t key_length,
- uint64_t offset,
- uint64_t *value)
+memcached_return_t memcached_increment_by_key(memcached_st *ptr,
+ const char *master_key, size_t master_key_length,
+ const char *key, size_t key_length,
+ uint64_t offset,
+ uint64_t *value)
{
- memcached_return rc= memcached_validate_key_length(key_length, ptr->flags.binary_protocol);
+ memcached_return_t rc= memcached_validate_key_length(key_length, ptr->flags.binary_protocol);
unlikely (rc != MEMCACHED_SUCCESS)
return rc;
return rc;
}
-memcached_return memcached_decrement_by_key(memcached_st *ptr,
- const char *master_key, size_t master_key_length,
- const char *key, size_t key_length,
- uint64_t offset,
- uint64_t *value)
+memcached_return_t memcached_decrement_by_key(memcached_st *ptr,
+ const char *master_key, size_t master_key_length,
+ const char *key, size_t key_length,
+ uint64_t offset,
+ uint64_t *value)
{
- memcached_return rc= memcached_validate_key_length(key_length, ptr->flags.binary_protocol);
+ memcached_return_t rc= memcached_validate_key_length(key_length, ptr->flags.binary_protocol);
unlikely (rc != MEMCACHED_SUCCESS)
return rc;
return rc;
}
-memcached_return memcached_increment_with_initial(memcached_st *ptr,
- const char *key,
- size_t key_length,
- uint64_t offset,
- uint64_t initial,
- time_t expiration,
- uint64_t *value)
+memcached_return_t memcached_increment_with_initial(memcached_st *ptr,
+ const char *key,
+ size_t key_length,
+ uint64_t offset,
+ uint64_t initial,
+ time_t expiration,
+ uint64_t *value)
{
return memcached_increment_with_initial_by_key(ptr, key, key_length,
key, key_length,
offset, initial, expiration, value);
}
-memcached_return memcached_increment_with_initial_by_key(memcached_st *ptr,
+memcached_return_t memcached_increment_with_initial_by_key(memcached_st *ptr,
const char *master_key,
size_t master_key_length,
const char *key,
time_t expiration,
uint64_t *value)
{
- memcached_return rc= memcached_validate_key_length(key_length, ptr->flags.binary_protocol);
+ memcached_return_t rc= memcached_validate_key_length(key_length, ptr->flags.binary_protocol);
unlikely (rc != MEMCACHED_SUCCESS)
return rc;
return rc;
}
-memcached_return memcached_decrement_with_initial(memcached_st *ptr,
- const char *key,
- size_t key_length,
- uint64_t offset,
- uint64_t initial,
- time_t expiration,
- uint64_t *value)
+memcached_return_t memcached_decrement_with_initial(memcached_st *ptr,
+ const char *key,
+ size_t key_length,
+ uint64_t offset,
+ uint64_t initial,
+ time_t expiration,
+ uint64_t *value)
{
return memcached_decrement_with_initial_by_key(ptr, key, key_length,
key, key_length,
offset, initial, expiration, value);
}
-memcached_return memcached_decrement_with_initial_by_key(memcached_st *ptr,
- const char *master_key,
- size_t master_key_length,
- const char *key,
- size_t key_length,
- uint64_t offset,
- uint64_t initial,
- time_t expiration,
- uint64_t *value)
+memcached_return_t memcached_decrement_with_initial_by_key(memcached_st *ptr,
+ const char *master_key,
+ size_t master_key_length,
+ const char *key,
+ size_t key_length,
+ uint64_t offset,
+ uint64_t initial,
+ time_t expiration,
+ uint64_t *value)
{
- memcached_return rc= memcached_validate_key_length(key_length, ptr->flags.binary_protocol);
+ memcached_return_t rc= memcached_validate_key_length(key_length, ptr->flags.binary_protocol);
unlikely (rc != MEMCACHED_SUCCESS)
return rc;
+/* LibMemcached
+ * Copyright (C) 2006-2009 Brian Aker
+ * All rights reserved.
+ *
+ * Use and distribution licensed under the BSD license. See
+ * the COPYING file in the parent directory for full text.
+ *
+ * Summary: Change the behavior of the memcached connection.
+ *
+ */
+
#include "common.h"
#include <time.h>
#include <sys/types.h>
We quit all connections so we can reset the sockets.
*/
-memcached_return memcached_behavior_set(memcached_st *ptr,
- memcached_behavior flag,
- uint64_t data)
+memcached_return_t memcached_behavior_set(memcached_st *ptr,
+ memcached_behavior_t flag,
+ uint64_t data)
{
switch (flag)
{
break;
case MEMCACHED_BEHAVIOR_DISTRIBUTION:
{
- ptr->distribution= (memcached_server_distribution)(data);
+ ptr->distribution= (memcached_server_distribution_t)(data);
if (ptr->distribution == MEMCACHED_DISTRIBUTION_RANDOM)
{
srandom((uint32_t) time(NULL));
break;
case MEMCACHED_BEHAVIOR_HASH:
#ifndef HAVE_HSIEH_HASH
- if ((memcached_hash)(data) == MEMCACHED_HASH_HSIEH)
+ if ((memcached_hash_t)(data) == MEMCACHED_HASH_HSIEH)
return MEMCACHED_FAILURE;
#endif
- ptr->hash= (memcached_hash)(data);
+ ptr->hash= (memcached_hash_t)(data);
break;
case MEMCACHED_BEHAVIOR_KETAMA_HASH:
- ptr->hash_continuum= (memcached_hash)(data);
+ ptr->hash_continuum= (memcached_hash_t)(data);
run_distribution(ptr);
break;
case MEMCACHED_BEHAVIOR_CACHE_LOOKUPS:
}
uint64_t memcached_behavior_get(memcached_st *ptr,
- memcached_behavior flag)
+ memcached_behavior_t flag)
{
switch (flag)
{
These functions provide data and function callback support
*/
-memcached_return memcached_callback_set(memcached_st *ptr,
- memcached_callback flag,
- void *data)
+memcached_return_t memcached_callback_set(memcached_st *ptr,
+ memcached_callback_t flag,
+ void *data)
{
switch (flag)
{
}
case MEMCACHED_CALLBACK_CLEANUP_FUNCTION:
{
- memcached_cleanup_func func= *(memcached_cleanup_func *)&data;
+ memcached_cleanup_fn func= *(memcached_cleanup_fn *)&data;
ptr->on_cleanup= func;
break;
}
case MEMCACHED_CALLBACK_CLONE_FUNCTION:
{
- memcached_clone_func func= *(memcached_clone_func *)&data;
+ memcached_clone_fn func= *(memcached_clone_fn *)&data;
ptr->on_clone= func;
break;
}
#endif
case MEMCACHED_CALLBACK_GET_FAILURE:
{
- memcached_trigger_key func= *(memcached_trigger_key *)&data;
+ memcached_trigger_key_fn func= *(memcached_trigger_key_fn *)&data;
ptr->get_key_failure= func;
break;
}
case MEMCACHED_CALLBACK_DELETE_TRIGGER:
{
- memcached_trigger_delete_key func= *(memcached_trigger_delete_key *)&data;
+ memcached_trigger_delete_key_fn func= *(memcached_trigger_delete_key_fn *)&data;
ptr->delete_trigger= func;
break;
}
}
void *memcached_callback_get(memcached_st *ptr,
- memcached_callback flag,
- memcached_return *error)
+ memcached_callback_t flag,
+ memcached_return_t *error)
{
- memcached_return local_error;
+ memcached_return_t local_error;
if (!error)
error = &local_error;
return *(void **)&ptr->delete_trigger;
}
default:
- WATCHPOINT_ASSERT(0);
- *error= MEMCACHED_FAILURE;
- return NULL;
+ WATCHPOINT_ASSERT(0);
+ *error= MEMCACHED_FAILURE;
+ return NULL;
}
}
#include <poll.h>
#include <sys/time.h>
-static memcached_return set_hostinfo(memcached_server_st *server)
+static memcached_return_t set_hostinfo(memcached_server_st *server)
{
struct addrinfo *ai;
struct addrinfo hints;
return MEMCACHED_SUCCESS;
}
-static memcached_return set_socket_options(memcached_server_st *ptr)
+static memcached_return_t set_socket_options(memcached_server_st *ptr)
{
WATCHPOINT_ASSERT(ptr->fd != -1);
return MEMCACHED_SUCCESS;
}
-static memcached_return unix_socket_connect(memcached_server_st *ptr)
+static memcached_return_t unix_socket_connect(memcached_server_st *ptr)
{
struct sockaddr_un servAddr;
socklen_t addrlen;
return MEMCACHED_SUCCESS;
}
-static memcached_return network_connect(memcached_server_st *ptr)
+static memcached_return_t network_connect(memcached_server_st *ptr)
{
if (ptr->fd == -1)
{
if (!ptr->sockaddr_inited ||
(!(ptr->root->flags.use_cache_lookups)))
{
- memcached_return rc;
+ memcached_return_t rc;
rc= set_hostinfo(ptr);
if (rc != MEMCACHED_SUCCESS)
}
-memcached_return memcached_connect(memcached_server_st *ptr)
+memcached_return_t memcached_connect(memcached_server_st *ptr)
{
- memcached_return rc= MEMCACHED_NO_SERVERS;
+ memcached_return_t rc= MEMCACHED_NO_SERVERS;
LIBMEMCACHED_MEMCACHED_CONNECT_START();
/* both retry_timeout and server_failure_limit must be set in order to delay retrying a server on error. */
MEMCACHED_E2BIG,
MEMCACHED_INVALID_ARGUMENTS,
MEMCACHED_MAXIMUM_RETURN /* Always add new error code before */
-} memcached_return;
+} memcached_return_t;
+
typedef enum {
MEMCACHED_DISTRIBUTION_MODULA,
MEMCACHED_DISTRIBUTION_CONSISTENT_KETAMA,
MEMCACHED_DISTRIBUTION_RANDOM,
MEMCACHED_DISTRIBUTION_CONSISTENT_KETAMA_SPY
-} memcached_server_distribution;
+} memcached_server_distribution_t;
typedef enum {
MEMCACHED_BEHAVIOR_NO_BLOCK,
MEMCACHED_BEHAVIOR_NUMBER_OF_REPLICAS,
MEMCACHED_BEHAVIOR_KETAMA_COMPAT_MODE,
MEMCACHED_BEHAVIOR_RANDOMIZE_REPLICA_READ
-} memcached_behavior;
+} memcached_behavior_t;
#define MEMCACHED_KETAMA_COMPAT_LIBMEMCACHED 0
#define MEMCACHED_KETAMA_COMPAT_SPY 1
#endif
MEMCACHED_CALLBACK_GET_FAILURE = 7,
MEMCACHED_CALLBACK_DELETE_TRIGGER = 8
-} memcached_callback;
+} memcached_callback_t;
typedef enum {
MEMCACHED_HASH_DEFAULT= 0,
MEMCACHED_HASH_HSIEH,
MEMCACHED_HASH_MURMUR,
MEMCACHED_HASH_JENKINS
-} memcached_hash;
+} memcached_hash_t;
typedef enum {
MEMCACHED_CONNECTION_UNKNOWN,
MEMCACHED_CONNECTION_TCP,
MEMCACHED_CONNECTION_UDP,
MEMCACHED_CONNECTION_UNIX_SOCKET
-} memcached_connection;
+} memcached_connection_t;
#endif /* __MEMCACHED_CONSTANTS_H__ */
#include "common.h"
#include "memcached/protocol_binary.h"
-memcached_return memcached_delete(memcached_st *ptr, const char *key, size_t key_length,
- time_t expiration)
+memcached_return_t memcached_delete(memcached_st *ptr, const char *key, size_t key_length,
+ time_t expiration)
{
return memcached_delete_by_key(ptr, key, key_length,
key, key_length, expiration);
}
-static inline memcached_return binary_delete(memcached_st *ptr,
- unsigned int server_key,
- const char *key,
- size_t key_length,
- uint8_t flush);
+static inline memcached_return_t binary_delete(memcached_st *ptr,
+ unsigned int server_key,
+ const char *key,
+ size_t key_length,
+ uint8_t flush);
-memcached_return memcached_delete_by_key(memcached_st *ptr,
- const char *master_key, size_t master_key_length,
- const char *key, size_t key_length,
- time_t expiration)
+memcached_return_t memcached_delete_by_key(memcached_st *ptr,
+ const char *master_key, size_t master_key_length,
+ const char *key, size_t key_length,
+ time_t expiration)
{
uint8_t to_write;
size_t send_length;
- memcached_return rc;
+ memcached_return_t rc;
char buffer[MEMCACHED_DEFAULT_COMMAND_SIZE];
unsigned int server_key;
return rc;
}
-static inline memcached_return binary_delete(memcached_st *ptr,
- unsigned int server_key,
- const char *key,
- size_t key_length,
- uint8_t flush)
+static inline memcached_return_t binary_delete(memcached_st *ptr,
+ unsigned int server_key,
+ const char *key,
+ size_t key_length,
+ uint8_t flush)
{
protocol_binary_request_delete request= {.bytes= {0}};
memcached_io_write(&ptr->hosts[server_key], NULL, 0, 1);
}
- memcached_return rc= MEMCACHED_SUCCESS;
+ memcached_return_t rc= MEMCACHED_SUCCESS;
if ((memcached_do(&ptr->hosts[server_key], request.bytes,
sizeof(request.bytes), 0) != MEMCACHED_SUCCESS) ||
#include "common.h"
-memcached_return memcached_do(memcached_server_st *ptr, const void *command,
- size_t command_length, uint8_t with_flush)
+memcached_return_t memcached_do(memcached_server_st *ptr, const void *command,
+ size_t command_length, uint8_t with_flush)
{
- memcached_return rc;
+ memcached_return_t rc;
ssize_t sent_length;
WATCHPOINT_ASSERT(command_length);
*/
#include "common.h"
-static memcached_return ascii_dump(memcached_st *ptr, memcached_dump_func *callback, void *context, uint32_t number_of_callbacks)
+static memcached_return_t ascii_dump(memcached_st *ptr, memcached_dump_fn *callback, void *context, uint32_t number_of_callbacks)
{
- memcached_return rc= 0;
+ memcached_return_t rc= 0;
char buffer[MEMCACHED_DEFAULT_COMMAND_SIZE];
size_t send_length;
uint32_t server_key;
return rc;
}
-memcached_return memcached_dump(memcached_st *ptr, memcached_dump_func *callback, void *context, uint32_t number_of_callbacks)
+memcached_return_t memcached_dump(memcached_st *ptr, memcached_dump_fn *callback, void *context, uint32_t number_of_callbacks)
{
/* No support for Binary protocol yet */
if (ptr->flags.binary_protocol)
char *memcached_fetch(memcached_st *ptr, char *key, size_t *key_length,
size_t *value_length,
uint32_t *flags,
- memcached_return *error)
+ memcached_return_t *error)
{
memcached_result_st *result_buffer= &ptr->result;
memcached_result_st *memcached_fetch_result(memcached_st *ptr,
memcached_result_st *result,
- memcached_return *error)
+ memcached_return_t *error)
{
memcached_server_st *server;
return NULL;
}
-memcached_return memcached_fetch_execute(memcached_st *ptr,
- memcached_execute_function *callback,
- void *context,
- unsigned int number_of_callbacks)
+memcached_return_t memcached_fetch_execute(memcached_st *ptr,
+ memcached_execute_fn *callback,
+ void *context,
+ uint32_t number_of_callbacks)
{
memcached_result_st *result= &ptr->result;
- memcached_return rc= MEMCACHED_FAILURE;
+ memcached_return_t rc= MEMCACHED_FAILURE;
unsigned int x;
while ((result= memcached_fetch_result(ptr, result, &rc)) != NULL)
#include "common.h"
-static memcached_return memcached_flush_binary(memcached_st *ptr,
- time_t expiration);
-static memcached_return memcached_flush_textual(memcached_st *ptr,
- time_t expiration);
+static memcached_return_t memcached_flush_binary(memcached_st *ptr,
+ time_t expiration);
+static memcached_return_t memcached_flush_textual(memcached_st *ptr,
+ time_t expiration);
-memcached_return memcached_flush(memcached_st *ptr, time_t expiration)
+memcached_return_t memcached_flush(memcached_st *ptr, time_t expiration)
{
- memcached_return rc;
+ memcached_return_t rc;
LIBMEMCACHED_MEMCACHED_FLUSH_START();
if (ptr->flags.binary_protocol)
return rc;
}
-static memcached_return memcached_flush_textual(memcached_st *ptr,
- time_t expiration)
+static memcached_return_t memcached_flush_textual(memcached_st *ptr,
+ time_t expiration)
{
unsigned int x;
size_t send_length;
- memcached_return rc;
+ memcached_return_t rc;
char buffer[MEMCACHED_DEFAULT_COMMAND_SIZE];
unlikely (ptr->number_of_hosts == 0)
return MEMCACHED_SUCCESS;
}
-static memcached_return memcached_flush_binary(memcached_st *ptr,
- time_t expiration)
+static memcached_return_t memcached_flush_binary(memcached_st *ptr,
+ time_t expiration)
{
unsigned int x;
protocol_binary_request_flush request= {.bytes= {0}};
for (x= 0; x < ptr->number_of_hosts; x++)
{
if (memcached_server_response_count(&ptr->hosts[x]) > 0)
- (void)memcached_response(&ptr->hosts[x], NULL, 0, NULL);
+ (void)memcached_response(&ptr->hosts[x], NULL, 0, NULL);
}
return MEMCACHED_SUCCESS;
#include "common.h"
#include "memcached_io.h"
-memcached_return memcached_flush_buffers(memcached_st *mem)
+memcached_return_t memcached_flush_buffers(memcached_st *mem)
{
- memcached_return ret= MEMCACHED_SUCCESS;
+ memcached_return_t ret= MEMCACHED_SUCCESS;
for (uint32_t x= 0; x < mem->number_of_hosts; ++x)
if (mem->hosts[x].write_buffer_offset != 0)
size_t key_length,
size_t *value_length,
uint32_t *flags,
- memcached_return *error)
+ memcached_return_t *error)
{
return memcached_get_by_key(ptr, NULL, 0, key, key_length, value_length,
flags, error);
}
-static memcached_return memcached_mget_by_key_real(memcached_st *ptr,
- const char *master_key,
- size_t master_key_length,
- const char * const *keys,
- const size_t *key_length,
- size_t number_of_keys,
- bool mget_mode);
+static memcached_return_t memcached_mget_by_key_real(memcached_st *ptr,
+ const char *master_key,
+ size_t master_key_length,
+ const char * const *keys,
+ const size_t *key_length,
+ size_t number_of_keys,
+ bool mget_mode);
char *memcached_get_by_key(memcached_st *ptr,
const char *master_key,
const char *key, size_t key_length,
size_t *value_length,
uint32_t *flags,
- memcached_return *error)
+ memcached_return_t *error)
{
char *value;
size_t dummy_length;
uint32_t dummy_flags;
- memcached_return dummy_error;
+ memcached_return_t dummy_error;
unlikely (ptr->flags.use_udp)
{
{
if (ptr->get_key_failure && *error == MEMCACHED_NOTFOUND)
{
- memcached_return rc;
+ memcached_return_t rc;
memcached_result_reset(&ptr->result);
rc= ptr->get_key_failure(ptr, key, key_length, &ptr->result);
return value;
}
-memcached_return memcached_mget(memcached_st *ptr,
- const char * const *keys,
- const size_t *key_length,
- size_t number_of_keys)
+memcached_return_t memcached_mget(memcached_st *ptr,
+ const char * const *keys,
+ const size_t *key_length,
+ size_t number_of_keys)
{
return memcached_mget_by_key(ptr, NULL, 0, keys, key_length, number_of_keys);
}
-static memcached_return binary_mget_by_key(memcached_st *ptr,
- unsigned int master_server_key,
- bool is_master_key_set,
- const char * const *keys,
- const size_t *key_length,
- size_t number_of_keys,
- bool mget_mode);
-
-static memcached_return memcached_mget_by_key_real(memcached_st *ptr,
- const char *master_key,
- size_t master_key_length,
- const char * const *keys,
- const size_t *key_length,
- size_t number_of_keys,
- bool mget_mode)
+static memcached_return_t binary_mget_by_key(memcached_st *ptr,
+ unsigned int master_server_key,
+ bool is_master_key_set,
+ const char * const *keys,
+ const size_t *key_length,
+ size_t number_of_keys,
+ bool mget_mode);
+
+static memcached_return_t memcached_mget_by_key_real(memcached_st *ptr,
+ const char *master_key,
+ size_t master_key_length,
+ const char * const *keys,
+ const size_t *key_length,
+ size_t number_of_keys,
+ bool mget_mode)
{
unsigned int x;
- memcached_return rc= MEMCACHED_NOTFOUND;
+ memcached_return_t rc= MEMCACHED_NOTFOUND;
const char *get_command= "get ";
uint8_t get_command_length= 4;
unsigned int master_server_key= (unsigned int)-1; /* 0 is a valid server id! */
bool is_master_key_set= false;
- unlikely (ptr->flags.use_udp)
+ unlikely (ptr->flags.use_udp)
return MEMCACHED_NOT_SUPPORTED;
LIBMEMCACHED_MEMCACHED_MGET_START();
return rc;
}
-memcached_return memcached_mget_by_key(memcached_st *ptr,
- const char *master_key,
- size_t master_key_length,
- const char * const *keys,
- const size_t *key_length,
- size_t number_of_keys)
+memcached_return_t memcached_mget_by_key(memcached_st *ptr,
+ const char *master_key,
+ size_t master_key_length,
+ const char * const *keys,
+ const size_t *key_length,
+ size_t number_of_keys)
{
return memcached_mget_by_key_real(ptr, master_key, master_key_length, keys,
key_length, number_of_keys, true);
}
-memcached_return memcached_mget_execute(memcached_st *ptr,
- const char * const *keys,
- const size_t *key_length,
- size_t number_of_keys,
- memcached_execute_function *callback,
- void *context,
- unsigned int number_of_callbacks)
+memcached_return_t memcached_mget_execute(memcached_st *ptr,
+ const char * const *keys,
+ const size_t *key_length,
+ size_t number_of_keys,
+ memcached_execute_fn *callback,
+ void *context,
+ unsigned int number_of_callbacks)
{
return memcached_mget_execute_by_key(ptr, NULL, 0, keys, key_length,
number_of_keys, callback,
context, number_of_callbacks);
}
-memcached_return memcached_mget_execute_by_key(memcached_st *ptr,
- const char *master_key,
- size_t master_key_length,
- const char * const *keys,
- const size_t *key_length,
- size_t number_of_keys,
- memcached_execute_function *callback,
- void *context,
- unsigned int number_of_callbacks)
+memcached_return_t memcached_mget_execute_by_key(memcached_st *ptr,
+ const char *master_key,
+ size_t master_key_length,
+ const char * const *keys,
+ const size_t *key_length,
+ size_t number_of_keys,
+ memcached_execute_fn *callback,
+ void *context,
+ unsigned int number_of_callbacks)
{
if ((ptr->flags.binary_protocol) == 0)
return MEMCACHED_NOT_SUPPORTED;
- memcached_return rc;
+ memcached_return_t rc;
memcached_callback_st *original_callbacks= ptr->callbacks;
memcached_callback_st cb= {
.callback= callback,
return rc;
}
-static memcached_return simple_binary_mget(memcached_st *ptr,
- unsigned int master_server_key,
- bool is_master_key_set,
- const char * const *keys,
- const size_t *key_length,
- size_t number_of_keys, bool mget_mode)
+static memcached_return_t simple_binary_mget(memcached_st *ptr,
+ unsigned int master_server_key,
+ bool is_master_key_set,
+ const char * const *keys,
+ const size_t *key_length,
+ size_t number_of_keys, bool mget_mode)
{
- memcached_return rc= MEMCACHED_NOTFOUND;
+ memcached_return_t rc= MEMCACHED_NOTFOUND;
uint32_t x;
int flush= number_of_keys == 1;
else
request.message.header.request.opcode= PROTOCOL_BINARY_CMD_GETK;
- memcached_return vk;
+ memcached_return_t vk;
vk= memcached_validate_key_length(key_length[x],
ptr->flags.binary_protocol);
unlikely (vk != MEMCACHED_SUCCESS)
{
/*
* Send a noop command to flush the buffers
- */
+ */
protocol_binary_request_noop request= {.bytes= {0}};
request.message.header.request.magic= PROTOCOL_BINARY_REQ;
request.message.header.request.opcode= PROTOCOL_BINARY_CMD_NOOP;
}
if (memcached_io_write(&ptr->hosts[x], request.bytes,
- sizeof(request.bytes), 1) == -1)
+ sizeof(request.bytes), 1) == -1)
{
memcached_server_response_reset(&ptr->hosts[x]);
memcached_io_reset(&ptr->hosts[x]);
rc= MEMCACHED_SOME_ERRORS;
}
}
- }
+ }
return rc;
}
-static memcached_return replication_binary_mget(memcached_st *ptr,
- uint32_t* hash,
- bool* dead_servers,
- const char *const *keys,
- const size_t *key_length,
- size_t number_of_keys)
+static memcached_return_t replication_binary_mget(memcached_st *ptr,
+ uint32_t* hash,
+ bool* dead_servers,
+ const char *const *keys,
+ const size_t *key_length,
+ size_t number_of_keys)
{
- memcached_return rc= MEMCACHED_NOTFOUND;
+ memcached_return_t rc= MEMCACHED_NOTFOUND;
uint32_t x, start= 0;
uint64_t randomize_read= memcached_behavior_get(ptr, MEMCACHED_BEHAVIOR_RANDOMIZE_REPLICA_READ);
if (randomize_read)
- start= (uint32_t)random() % (uint32_t)(ptr->number_of_replicas + 1);
+ start= (uint32_t)random() % (uint32_t)(ptr->number_of_replicas + 1);
/* Loop for each replica */
for (uint32_t replica= 0; replica <= ptr->number_of_replicas; ++replica)
* and we used the callback interface from memcached_mget_execute so
* that we might have processed some of the responses etc. For now,
* just make sure we work _correctly_
- */
+ */
if ((memcached_io_write(&ptr->hosts[server], request.bytes,
sizeof(request.bytes), 0) == -1) ||
(memcached_io_write(&ptr->hosts[server], keys[x],
return rc;
}
-static memcached_return binary_mget_by_key(memcached_st *ptr,
- unsigned int master_server_key,
- bool is_master_key_set,
- const char * const *keys,
- const size_t *key_length,
- size_t number_of_keys,
- bool mget_mode)
+static memcached_return_t binary_mget_by_key(memcached_st *ptr,
+ unsigned int master_server_key,
+ bool is_master_key_set,
+ const char * const *keys,
+ const size_t *key_length,
+ size_t number_of_keys,
+ bool mget_mode)
{
- memcached_return rc;
+ memcached_return_t rc;
if (ptr->number_of_replicas == 0)
{
const char *key, size_t key_length,
size_t *value_length,
uint32_t *flags,
- memcached_return *error);
+ memcached_return_t *error);
LIBMEMCACHED_API
-memcached_return memcached_mget(memcached_st *ptr,
- const char * const *keys,
- const size_t *key_length,
- size_t number_of_keys);
+memcached_return_t memcached_mget(memcached_st *ptr,
+ const char * const *keys,
+ const size_t *key_length,
+ size_t number_of_keys);
LIBMEMCACHED_API
char *memcached_get_by_key(memcached_st *ptr,
const char *key, size_t key_length,
size_t *value_length,
uint32_t *flags,
- memcached_return *error);
+ memcached_return_t *error);
LIBMEMCACHED_API
-memcached_return memcached_mget_by_key(memcached_st *ptr,
- const char *master_key, size_t
- master_key_length,
- const char * const *keys,
- const size_t *key_length,
- size_t number_of_keys);
+memcached_return_t memcached_mget_by_key(memcached_st *ptr,
+ const char *master_key, size_t
+ master_key_length,
+ const char * const *keys,
+ const size_t *key_length,
+ size_t number_of_keys);
LIBMEMCACHED_API
char *memcached_fetch(memcached_st *ptr,
char *key, size_t *key_length,
size_t *value_length, uint32_t *flags,
- memcached_return *error);
+ memcached_return_t *error);
LIBMEMCACHED_API
memcached_result_st *memcached_fetch_result(memcached_st *ptr,
memcached_result_st *result,
- memcached_return *error);
+ memcached_return_t *error);
LIBMEMCACHED_API
-memcached_return memcached_mget_execute(memcached_st *ptr,
- const char * const *keys,
- const size_t *key_length,
- size_t number_of_keys,
- memcached_execute_function *callback,
- void *context,
- unsigned int number_of_callbacks);
+memcached_return_t memcached_mget_execute(memcached_st *ptr,
+ const char * const *keys,
+ const size_t *key_length,
+ size_t number_of_keys,
+ memcached_execute_fn *callback,
+ void *context,
+ unsigned int number_of_callbacks);
LIBMEMCACHED_API
-memcached_return memcached_mget_execute_by_key(memcached_st *ptr,
- const char *master_key,
- size_t master_key_length,
- const char * const *keys,
- const size_t *key_length,
- size_t number_of_keys,
- memcached_execute_function *callback,
- void *context,
- unsigned int number_of_callbacks);
+memcached_return_t memcached_mget_execute_by_key(memcached_st *ptr,
+ const char *master_key,
+ size_t master_key_length,
+ const char * const *keys,
+ const size_t *key_length,
+ size_t number_of_keys,
+ memcached_execute_fn *callback,
+ void *context,
+ unsigned int number_of_callbacks);
#ifdef __cplusplus
}
static uint32_t internal_generate_hash(const char *key, size_t key_length);
static uint32_t internal_generate_md5(const char *key, size_t key_length);
-uint32_t memcached_generate_hash_value(const char *key, size_t key_length, memcached_hash hash_algorithm)
+uint32_t memcached_generate_hash_value(const char *key, size_t key_length, memcached_hash_t hash_algorithm)
{
uint32_t hash= 1; /* Just here to remove compile warning */
uint32_t x= 0;
#include <math.h>
/* Protoypes (static) */
-static memcached_return server_add(memcached_st *ptr, const char *hostname,
- unsigned int port,
- uint32_t weight,
- memcached_connection type);
-memcached_return update_continuum(memcached_st *ptr);
+static memcached_return_t server_add(memcached_st *ptr, const char *hostname,
+ in_port_t port,
+ uint32_t weight,
+ memcached_connection_t type);
+memcached_return_t update_continuum(memcached_st *ptr);
static int compare_servers(const void *p1, const void *p2)
{
}
-memcached_return run_distribution(memcached_st *ptr)
+memcached_return_t run_distribution(memcached_st *ptr)
{
switch (ptr->distribution)
{
return -1;
}
-memcached_return update_continuum(memcached_st *ptr)
+memcached_return_t update_continuum(memcached_st *ptr)
{
uint32_t host_index;
uint32_t continuum_index= 0;
}
-memcached_return memcached_server_push(memcached_st *ptr, memcached_server_st *list)
+memcached_return_t memcached_server_push(memcached_st *ptr, memcached_server_st *list)
{
unsigned int x;
uint16_t count;
return run_distribution(ptr);
}
-memcached_return memcached_server_add_unix_socket(memcached_st *ptr,
- const char *filename)
+memcached_return_t memcached_server_add_unix_socket(memcached_st *ptr,
+ const char *filename)
{
return memcached_server_add_unix_socket_with_weight(ptr, filename, 0);
}
-memcached_return memcached_server_add_unix_socket_with_weight(memcached_st *ptr,
- const char *filename,
- uint32_t weight)
+memcached_return_t memcached_server_add_unix_socket_with_weight(memcached_st *ptr,
+ const char *filename,
+ uint32_t weight)
{
if (!filename)
return MEMCACHED_FAILURE;
return server_add(ptr, filename, 0, weight, MEMCACHED_CONNECTION_UNIX_SOCKET);
}
-memcached_return memcached_server_add_udp(memcached_st *ptr,
- const char *hostname,
- unsigned int port)
+memcached_return_t memcached_server_add_udp(memcached_st *ptr,
+ const char *hostname,
+ in_port_t port)
{
return memcached_server_add_udp_with_weight(ptr, hostname, port, 0);
}
-memcached_return memcached_server_add_udp_with_weight(memcached_st *ptr,
- const char *hostname,
- unsigned int port,
- uint32_t weight)
+memcached_return_t memcached_server_add_udp_with_weight(memcached_st *ptr,
+ const char *hostname,
+ in_port_t port,
+ uint32_t weight)
{
if (!port)
port= MEMCACHED_DEFAULT_PORT;
return server_add(ptr, hostname, port, weight, MEMCACHED_CONNECTION_UDP);
}
-memcached_return memcached_server_add(memcached_st *ptr,
- const char *hostname,
- unsigned int port)
+memcached_return_t memcached_server_add(memcached_st *ptr,
+ const char *hostname,
+ in_port_t port)
{
return memcached_server_add_with_weight(ptr, hostname, port, 0);
}
-memcached_return memcached_server_add_with_weight(memcached_st *ptr,
- const char *hostname,
- unsigned int port,
- uint32_t weight)
+memcached_return_t memcached_server_add_with_weight(memcached_st *ptr,
+ const char *hostname,
+ in_port_t port,
+ uint32_t weight)
{
if (!port)
port= MEMCACHED_DEFAULT_PORT;
return server_add(ptr, hostname, port, weight, MEMCACHED_CONNECTION_TCP);
}
-static memcached_return server_add(memcached_st *ptr, const char *hostname,
- unsigned int port,
- uint32_t weight,
- memcached_connection type)
+static memcached_return_t server_add(memcached_st *ptr, const char *hostname,
+ in_port_t port,
+ uint32_t weight,
+ memcached_connection_t type)
{
memcached_server_st *new_host_list;
return run_distribution(ptr);
}
-memcached_return memcached_server_remove(memcached_server_st *st_ptr)
+memcached_return_t memcached_server_remove(memcached_server_st *st_ptr)
{
uint32_t x, host_index;
memcached_st *ptr= st_ptr->root;
}
memcached_server_st *memcached_server_list_append(memcached_server_st *ptr,
- const char *hostname, unsigned int port,
- memcached_return *error)
+ const char *hostname, in_port_t port,
+ memcached_return_t *error)
{
return memcached_server_list_append_with_weight(ptr, hostname, port, 0, error);
}
memcached_server_st *memcached_server_list_append_with_weight(memcached_server_st *ptr,
- const char *hostname, unsigned int port,
+ const char *hostname, in_port_t port,
uint32_t weight,
- memcached_return *error)
+ memcached_return_t *error)
{
unsigned int count;
memcached_server_st *new_host_list;
MEM_WRITE
} memc_read_or_write;
-static ssize_t io_flush(memcached_server_st *ptr, memcached_return *error);
+static ssize_t io_flush(memcached_server_st *ptr, memcached_return_t *error);
static void increment_udp_message_id(memcached_server_st *ptr);
-static memcached_return io_wait(memcached_server_st *ptr,
- memc_read_or_write read_or_write)
+static memcached_return_t io_wait(memcached_server_st *ptr,
+ memc_read_or_write read_or_write)
{
struct pollfd fds= {
- .fd= ptr->fd,
- .events = POLLIN
+ .fd= ptr->fd,
+ .events = POLLIN
};
int error;
fds.events= POLLOUT;
/*
- ** We are going to block on write, but at least on Solaris we might block
- ** on write if we haven't read anything from our input buffer..
- ** Try to purge the input buffer if we don't do any flow control in the
- ** application layer (just sending a lot of data etc)
- ** The test is moved down in the purge function to avoid duplication of
- ** the test.
- */
+ ** We are going to block on write, but at least on Solaris we might block
+ ** on write if we haven't read anything from our input buffer..
+ ** Try to purge the input buffer if we don't do any flow control in the
+ ** application layer (just sending a lot of data etc)
+ ** The test is moved down in the purge function to avoid duplication of
+ ** the test.
+ */
if (read_or_write == MEM_WRITE)
{
- memcached_return rc= memcached_purge(ptr);
+ memcached_return_t rc= memcached_purge(ptr);
if (rc != MEMCACHED_SUCCESS && rc != MEMCACHED_STORED)
return MEMCACHED_FAILURE;
}
if (ptr->read_ptr != ptr->read_buffer)
{
/* Move all of the data to the beginning of the buffer so
- ** that we can fit more data into the buffer...
- */
+ ** that we can fit more data into the buffer...
+ */
memmove(ptr->read_buffer, ptr->read_ptr, ptr->read_buffer_length);
ptr->read_ptr= ptr->read_buffer;
ptr->read_data_length= ptr->read_buffer_length;
static bool process_input_buffer(memcached_server_st *ptr)
{
/*
- ** We might be able to process some of the response messages if we
- ** have a callback set up
- */
+ ** We might be able to process some of the response messages if we
+ ** have a callback set up
+ */
if (ptr->root->callbacks != NULL && ptr->root->flags.use_udp == false)
{
/*
* We might have responses... try to read them out and fire
* callbacks
- */
+ */
memcached_callback_st cb= *ptr->root->callbacks;
char buffer[MEMCACHED_DEFAULT_COMMAND_SIZE];
- memcached_return error;
+ memcached_return_t error;
error= memcached_response(ptr, buffer, sizeof(buffer),
&ptr->root->result);
if (error == MEMCACHED_SUCCESS)
}
#endif
-memcached_return memcached_io_read(memcached_server_st *ptr,
- void *buffer, size_t length, ssize_t *nread)
+memcached_return_t memcached_io_read(memcached_server_st *ptr,
+ void *buffer, size_t length, ssize_t *nread)
{
char *buffer_ptr;
else if (data_read == -1)
{
ptr->cached_errno= errno;
- memcached_return rc= MEMCACHED_UNKNOWN_READ_FAILURE;
+ memcached_return_t rc= MEMCACHED_UNKNOWN_READ_FAILURE;
switch (errno)
{
case EAGAIN:
case EINTR:
if ((rc= io_wait(ptr, MEM_READ)) == MEMCACHED_SUCCESS)
continue;
- /* fall through */
+ /* fall through */
default:
{
if (ptr->write_buffer_offset == buffer_end && ptr->type != MEMCACHED_CONNECTION_UDP)
{
- memcached_return rc;
+ memcached_return_t rc;
ssize_t sent_length;
WATCHPOINT_ASSERT(ptr->fd != -1);
if (with_flush)
{
- memcached_return rc;
+ memcached_return_t rc;
WATCHPOINT_ASSERT(ptr->fd != -1);
if (io_flush(ptr, &rc) == -1)
return -1;
return (ssize_t) original_length;
}
-memcached_return memcached_io_close(memcached_server_st *ptr)
+memcached_return_t memcached_io_close(memcached_server_st *ptr)
{
int r;
}
static ssize_t io_flush(memcached_server_st *ptr,
- memcached_return *error)
+ memcached_return_t *error)
{
/*
- ** We might want to purge the input buffer if we haven't consumed
- ** any output yet... The test for the limits is the purge is inline
- ** in the purge function to avoid duplicating the logic..
- */
+ ** We might want to purge the input buffer if we haven't consumed
+ ** any output yet... The test for the limits is the purge is inline
+ ** in the purge function to avoid duplicating the logic..
+ */
{
- memcached_return rc;
- WATCHPOINT_ASSERT(ptr->fd != -1);
- rc= memcached_purge(ptr);
+ memcached_return_t rc;
+ WATCHPOINT_ASSERT(ptr->fd != -1);
+ rc= memcached_purge(ptr);
- if (rc != MEMCACHED_SUCCESS && rc != MEMCACHED_STORED)
- return -1;
+ if (rc != MEMCACHED_SUCCESS && rc != MEMCACHED_STORED)
+ return -1;
}
ssize_t sent_length;
size_t return_length;
return -1;
if (ptr->write_buffer_offset == 0 || (ptr->type == MEMCACHED_CONNECTION_UDP
- && ptr->write_buffer_offset == UDP_DATAGRAM_HEADER_LENGTH))
+ && ptr->write_buffer_offset == UDP_DATAGRAM_HEADER_LENGTH))
return 0;
/* Looking for memory overflows */
case ENOBUFS:
continue;
case EAGAIN:
- {
- /*
- * We may be blocked on write because the input buffer
- * is full. Let's check if we have room in our input
- * buffer for more data and retry the write before
- * waiting..
+ {
+ /*
+ * We may be blocked on write because the input buffer
+ * is full. Let's check if we have room in our input
+ * buffer for more data and retry the write before
+ * waiting..
*/
- if (repack_input_buffer(ptr) ||
- process_input_buffer(ptr))
- continue;
+ if (repack_input_buffer(ptr) ||
+ process_input_buffer(ptr))
+ continue;
- memcached_return rc;
- rc= io_wait(ptr, MEM_WRITE);
+ memcached_return_t rc;
+ rc= io_wait(ptr, MEM_WRITE);
- if (rc == MEMCACHED_SUCCESS || rc == MEMCACHED_TIMEOUT)
- continue;
+ if (rc == MEMCACHED_SUCCESS || rc == MEMCACHED_TIMEOUT)
+ continue;
- memcached_quit_server(ptr, 1);
- return -1;
- }
+ memcached_quit_server(ptr, 1);
+ return -1;
+ }
default:
memcached_quit_server(ptr, 1);
*error= MEMCACHED_ERRNO;
* Read a given number of bytes from the server and place it into a specific
* buffer. Reset the IO channel on this server if an error occurs.
*/
-memcached_return memcached_safe_read(memcached_server_st *ptr,
- void *dta,
- size_t size)
+memcached_return_t memcached_safe_read(memcached_server_st *ptr,
+ void *dta,
+ size_t size)
{
size_t offset= 0;
char *data= dta;
while (offset < size)
{
ssize_t nread;
- memcached_return rc= memcached_io_read(ptr, data + offset, size - offset,
- &nread);
+ memcached_return_t rc= memcached_io_read(ptr, data + offset, size - offset,
+ &nread);
if (rc != MEMCACHED_SUCCESS)
return rc;
return MEMCACHED_SUCCESS;
}
-memcached_return memcached_io_readline(memcached_server_st *ptr,
- char *buffer_ptr,
- size_t size)
+memcached_return_t memcached_io_readline(memcached_server_st *ptr,
+ char *buffer_ptr,
+ size_t size)
{
bool line_complete= false;
size_t total_nr= 0;
* We don't have any data in the buffer, so let's fill the read
* buffer. Call the standard read function to avoid duplicating
* the logic.
- */
+ */
ssize_t nread;
- memcached_return rc= memcached_io_read(ptr, buffer_ptr, 1, &nread);
+ memcached_return_t rc= memcached_io_read(ptr, buffer_ptr, 1, &nread);
if (rc != MEMCACHED_SUCCESS)
return rc;
header->request_id= htons((uint16_t) (thread_id | msg_num));
}
-memcached_return memcached_io_init_udp_header(memcached_server_st *ptr, uint16_t thread_id)
+memcached_return_t memcached_io_init_udp_header(memcached_server_st *ptr, uint16_t thread_id)
{
if (thread_id > UDP_REQUEST_ID_MAX_THREAD_ID)
return MEMCACHED_FAILURE;
-/*
- * Summary: Server IO, Not public!
+/* LibMemcached
+ * Copyright (C) 2006-2009 Brian Aker
+ * All rights reserved.
+ *
+ * Use and distribution licensed under the BSD license. See
+ * the COPYING file in the parent directory for full text.
*
- * Copy: See Copyright for the status of this software.
+ * Summary: Server IO, Not public!
*
- * Author: Brian Aker
*/
#ifndef LIBMEMCACHED_MEMCACHED_IO_H
#define LIBMEMCACHED_MEMCACHED_IO_H
+#ifdef __cplusplus
+extern "C" {
+#endif
+
#if defined(BUILDING_LIBMEMCACHED)
#include "libmemcached/memcached.h"
ssize_t memcached_io_write(memcached_server_st *ptr,
const void *buffer, size_t length, char with_flush);
void memcached_io_reset(memcached_server_st *ptr);
-memcached_return memcached_io_read(memcached_server_st *ptr,
- void *buffer, size_t length, ssize_t *nread);
+memcached_return_t memcached_io_read(memcached_server_st *ptr,
+ void *buffer, size_t length, ssize_t *nread);
/* Read a line (terminated by '\n') into the buffer */
-memcached_return memcached_io_readline(memcached_server_st *ptr,
- char *buffer_ptr,
- size_t size);
-memcached_return memcached_io_close(memcached_server_st *ptr);
+memcached_return_t memcached_io_readline(memcached_server_st *ptr,
+ char *buffer_ptr,
+ size_t size);
+memcached_return_t memcached_io_close(memcached_server_st *ptr);
/* Read n bytes of data from the server and store them in dta */
-memcached_return memcached_safe_read(memcached_server_st *ptr,
- void *dta,
- size_t size);
+memcached_return_t memcached_safe_read(memcached_server_st *ptr,
+ void *dta,
+ size_t size);
/* Read a single response from the server */
-memcached_return memcached_read_one_response(memcached_server_st *ptr,
- char *buffer, size_t buffer_length,
- memcached_result_st *result);
-memcached_return memcached_io_init_udp_header(memcached_server_st *ptr,
- uint16_t thread_id);
+memcached_return_t memcached_read_one_response(memcached_server_st *ptr,
+ char *buffer, size_t buffer_length,
+ memcached_result_st *result);
+memcached_return_t memcached_io_init_udp_header(memcached_server_st *ptr,
+ uint16_t thread_id);
memcached_server_st *memcached_io_get_readable_server(memcached_st *memc);
#endif /* BUILDING_LIBMEMCACHED */
+
+#ifdef __cplusplus
+}
+#endif
+
#endif /* LIBMEMCACHED_MEMCACHED_IO_H */
#include "common.h"
-memcached_return memcached_key_test(const char * const *keys,
- const size_t *key_length,
- size_t number_of_keys)
+memcached_return_t memcached_key_test(const char * const *keys,
+ const size_t *key_length,
+ size_t number_of_keys)
{
uint32_t x;
- memcached_return rc;
+ memcached_return_t rc;
for (x= 0; x < number_of_keys; x++)
{
const char *begin_ptr;
const char *end_ptr;
memcached_server_st *servers= NULL;
- memcached_return rc;
+ memcached_return_t rc;
WATCHPOINT_ASSERT(server_strings);
LIBMEMCACHED_API
memcached_st* memcached_pool_pop(memcached_pool_st* pool,
bool block,
- memcached_return* rc);
+ memcached_return_t* rc);
LIBMEMCACHED_API
-memcached_return memcached_pool_push(memcached_pool_st* pool,
+memcached_return_t memcached_pool_push(memcached_pool_st* pool,
memcached_st* mmc);
LIBMEMCACHED_API
-memcached_return memcached_pool_behavior_set(memcached_pool_st *ptr, memcached_behavior flag, uint64_t data);
+memcached_return_t memcached_pool_behavior_set(memcached_pool_st *ptr,
+ memcached_behavior_t flag,
+ uint64_t data);
LIBMEMCACHED_API
-memcached_return memcached_pool_behavior_get(memcached_pool_st *ptr, memcached_behavior flag, uint64_t *value);
+memcached_return_t memcached_pool_behavior_get(memcached_pool_st *ptr,
+ memcached_behavior_t flag,
+ uint64_t *value);
#ifdef __cplusplus
}
#include "memcached_io.h"
#include "memcached_constants.h"
-memcached_return memcached_purge(memcached_server_st *ptr)
+memcached_return_t memcached_purge(memcached_server_st *ptr)
{
uint32_t x;
- memcached_return ret= MEMCACHED_SUCCESS;
+ memcached_return_t ret= MEMCACHED_SUCCESS;
if (ptr->root->options.is_purging || /* already purging */
(memcached_server_response_count(ptr) < ptr->root->io_msg_watermark &&
- ptr->io_bytes_sent < ptr->root->io_bytes_watermark) ||
+ ptr->io_bytes_sent < ptr->root->io_bytes_watermark) ||
(ptr->io_bytes_sent >= ptr->root->io_bytes_watermark &&
- memcached_server_response_count(ptr) < 2))
+ memcached_server_response_count(ptr) < 2))
{
return MEMCACHED_SUCCESS;
}
/* memcached_io_write and memcached_response may call memcached_purge
- so we need to be able stop any recursion.. */
+ so we need to be able stop any recursion.. */
ptr->root->options.is_purging= true;
WATCHPOINT_ASSERT(ptr->fd != -1);
/* Force a flush of the buffer to ensure that we don't have the n-1 pending
- requests buffered up.. */
+ requests buffered up.. */
if (memcached_io_write(ptr, NULL, 0, 1) == -1)
{
ptr->root->options.is_purging= true;
* We need to increase the timeout, because we might be waiting for
* data to be sent from the server (the commands was in the output buffer
* and just flushed
- */
+ */
int32_t timeo= ptr->root->poll_timeout;
ptr->root->poll_timeout= 2000;
for (x= 0; x < no_msg; x++)
{
memcached_result_reset(result_ptr);
- memcached_return rc= memcached_read_one_response(ptr, buffer,
- sizeof (buffer),
- result_ptr);
+ memcached_return_t rc= memcached_read_one_response(ptr, buffer,
+ sizeof (buffer),
+ result_ptr);
/*
* Purge doesn't care for what kind of command results that is received.
* The only kind of errors I care about if is I'm out of sync with the
* protocol or have problems reading data from the network..
- */
+ */
if (rc== MEMCACHED_PROTOCOL_ERROR || rc == MEMCACHED_UNKNOWN_READ_FAILURE)
{
WATCHPOINT_ERROR(rc);
{
if (io_death == 0 && ptr->type != MEMCACHED_CONNECTION_UDP)
{
- memcached_return rc;
+ memcached_return_t rc;
char buffer[MEMCACHED_MAX_BUFFER];
if (ptr->root->flags.binary_protocol)
#include "common.h"
#include "memcached_io.h"
-static memcached_return textual_read_one_response(memcached_server_st *ptr,
+static memcached_return_t textual_read_one_response(memcached_server_st *ptr,
char *buffer, size_t buffer_length,
memcached_result_st *result);
-static memcached_return binary_read_one_response(memcached_server_st *ptr,
+static memcached_return_t binary_read_one_response(memcached_server_st *ptr,
char *buffer, size_t buffer_length,
memcached_result_st *result);
-memcached_return memcached_read_one_response(memcached_server_st *ptr,
+memcached_return_t memcached_read_one_response(memcached_server_st *ptr,
char *buffer, size_t buffer_length,
memcached_result_st *result)
{
if (result == NULL)
result = &ptr->root->result;
- memcached_return rc;
+ memcached_return_t rc;
if (ptr->root->flags.binary_protocol)
rc= binary_read_one_response(ptr, buffer, buffer_length, result);
else
return rc;
}
-memcached_return memcached_response(memcached_server_st *ptr,
+memcached_return_t memcached_response(memcached_server_st *ptr,
char *buffer, size_t buffer_length,
memcached_result_st *result)
{
if (ptr->root->flags.binary_protocol == false)
while (memcached_server_response_count(ptr) > 1)
{
- memcached_return rc= memcached_read_one_response(ptr, buffer, buffer_length, result);
+ memcached_return_t rc= memcached_read_one_response(ptr, buffer, buffer_length, result);
unlikely (rc != MEMCACHED_END &&
rc != MEMCACHED_STORED &&
return memcached_read_one_response(ptr, buffer, buffer_length, result);
}
-static memcached_return textual_value_fetch(memcached_server_st *ptr,
+static memcached_return_t textual_value_fetch(memcached_server_st *ptr,
char *buffer,
memcached_result_st *result)
{
- memcached_return rc= MEMCACHED_SUCCESS;
+ memcached_return_t rc= MEMCACHED_SUCCESS;
char *string_ptr;
char *end_ptr;
char *next_ptr;
*/
to_read= (value_length) + 2;
ssize_t read_length= 0;
- memcached_return rrc= memcached_io_read(ptr, value_ptr, to_read, &read_length);
+ memcached_return_t rrc= memcached_io_read(ptr, value_ptr, to_read, &read_length);
if (rrc != MEMCACHED_SUCCESS)
return rrc;
return MEMCACHED_PARTIAL_READ;
}
-static memcached_return textual_read_one_response(memcached_server_st *ptr,
+static memcached_return_t textual_read_one_response(memcached_server_st *ptr,
char *buffer, size_t buffer_length,
memcached_result_st *result)
{
- memcached_return rc= memcached_io_readline(ptr, buffer, buffer_length);
+ memcached_return_t rc= memcached_io_readline(ptr, buffer, buffer_length);
if (rc != MEMCACHED_SUCCESS)
return rc;
return memcached_string_length(sptr);
}
-static memcached_return binary_read_one_response(memcached_server_st *ptr,
+static memcached_return_t binary_read_one_response(memcached_server_st *ptr,
char *buffer, size_t buffer_length,
memcached_result_st *result)
{
}
}
- memcached_return rc= MEMCACHED_SUCCESS;
+ memcached_return_t rc= MEMCACHED_SUCCESS;
unlikely(header.response.status != 0)
switch (header.response.status)
{
/*
NOTE turn into macro
*/
-memcached_return memcached_result_set_value(memcached_result_st *ptr, const char *value, size_t length)
+memcached_return_t memcached_result_set_value(memcached_result_st *ptr, const char *value, size_t length)
{
return memcached_string_append(&ptr->value, value, length);
}
#define memcached_result_flags(A) (A)->flags
#define memcached_result_cas(A) (A)->cas
LIBMEMCACHED_API
-memcached_return memcached_result_set_value(memcached_result_st *ptr, const char *value, size_t length);
+memcached_return_t memcached_result_set_value(memcached_result_st *ptr, const char *value, size_t length);
#define memcached_result_set_flags(A,B) (A)->flags=(B)
#define memcached_result_set_expiration(A,B) (A)->expiration=(B)
}
memcached_server_st *memcached_server_create_with(memcached_st *memc, memcached_server_st *host,
- const char *hostname, unsigned int port,
- uint32_t weight, memcached_connection type)
+ const char *hostname, in_port_t port,
+ uint32_t weight, memcached_connection_t type)
{
host= memcached_server_create(memc, host);
}
-memcached_return memcached_server_cursor(memcached_st *ptr,
- memcached_server_function *callback,
- void *context,
- unsigned int number_of_callbacks)
+memcached_return_t memcached_server_cursor(memcached_st *ptr,
+ memcached_server_fn *callback,
+ void *context,
+ uint32_t number_of_callbacks)
{
unsigned int y;
return MEMCACHED_SUCCESS;
}
-memcached_server_st *memcached_server_by_key(memcached_st *ptr, const char *key, size_t key_length, memcached_return *error)
+memcached_server_st *memcached_server_by_key(memcached_st *ptr, const char *key, size_t key_length, memcached_return_t *error)
{
uint32_t server_key;
uint8_t major_version;
uint8_t micro_version;
uint8_t minor_version;
- memcached_connection type;
+ memcached_connection_t type;
char *read_ptr;
char *cached_server_error;
size_t read_buffer_length;
#define memcached_server_response_count(A) (A)->cursor_active
LIBMEMCACHED_API
-memcached_return memcached_server_cursor(memcached_st *ptr,
- memcached_server_function *callback,
- void *context,
- unsigned int number_of_callbacks);
+memcached_return_t memcached_server_cursor(memcached_st *ptr,
+ memcached_server_fn *callback,
+ void *context,
+ uint32_t number_of_callbacks);
LIBMEMCACHED_API
memcached_server_st *memcached_server_by_key(memcached_st *ptr, const char *key,
- size_t key_length, memcached_return *error);
+ size_t key_length, memcached_return_t *error);
LIBMEMCACHED_API
const char *memcached_server_error(memcached_server_st *ptr);
LIBMEMCACHED_API
memcached_server_st *memcached_server_create_with(memcached_st *memc, memcached_server_st *host,
- const char *hostname, unsigned int port,
- uint32_t weight, memcached_connection type);
+ const char *hostname, in_port_t port,
+ uint32_t weight, memcached_connection_t type);
LIBMEMCACHED_API
void memcached_server_free(memcached_server_st *ptr);
memcached_server_st *memcached_server_clone(memcached_server_st *clone, memcached_server_st *ptr);
LIBMEMCACHED_API
memcached_analysis_st *memcached_analyze(memcached_st *memc, memcached_stat_st *memc_stat,
- memcached_return *error);
+ memcached_return_t *error);
LIBMEMCACHED_API
-memcached_return memcached_server_remove(memcached_server_st *st_ptr);
+memcached_return_t memcached_server_remove(memcached_server_st *st_ptr);
LIBMEMCACHED_API
memcached_server_st *memcached_server_get_last_disconnect(memcached_st *ptr);
};
-static memcached_return set_data(memcached_stat_st *memc_stat, char *key, char *value)
+static memcached_return_t set_data(memcached_stat_st *memc_stat, char *key, char *value)
{
if (strlen(key) < 1)
}
char *memcached_stat_get_value(memcached_st *ptr, memcached_stat_st *memc_stat,
- const char *key, memcached_return *error)
+ const char *key, memcached_return_t *error)
{
char buffer[SMALL_STRING_LEN];
int length;
return ret;
}
-static memcached_return binary_stats_fetch(memcached_st *ptr,
- memcached_stat_st *memc_stat,
- char *args,
- unsigned int server_key)
+static memcached_return_t binary_stats_fetch(memcached_st *ptr,
+ memcached_stat_st *memc_stat,
+ char *args,
+ unsigned int server_key)
{
- memcached_return rc;
+ memcached_return_t rc;
char buffer[MEMCACHED_DEFAULT_COMMAND_SIZE];
protocol_binary_request_stats request= {.bytes= {0}};
request.message.header.request.keylen= htons((uint16_t)len);
request.message.header.request.bodylen= htonl((uint32_t) len);
-
+
if ((memcached_do(&ptr->hosts[server_key], request.bytes,
sizeof(request.bytes), 0) != MEMCACHED_SUCCESS) ||
(memcached_io_write(&ptr->hosts[server_key], args, len, 1) == -1))
memcached_server_response_decrement(&ptr->hosts[server_key]);
do
{
- rc= memcached_response(&ptr->hosts[server_key], buffer,
- sizeof(buffer), NULL);
- if (rc == MEMCACHED_END)
- break;
-
- unlikely (rc != MEMCACHED_SUCCESS)
- {
- memcached_io_reset(&ptr->hosts[server_key]);
- return rc;
- }
-
- unlikely((set_data(memc_stat, buffer, buffer + strlen(buffer) + 1)) == MEMCACHED_UNKNOWN_STAT_KEY)
- {
- WATCHPOINT_ERROR(MEMCACHED_UNKNOWN_STAT_KEY);
- WATCHPOINT_ASSERT(0);
- }
+ rc= memcached_response(&ptr->hosts[server_key], buffer,
+ sizeof(buffer), NULL);
+ if (rc == MEMCACHED_END)
+ break;
+
+ unlikely (rc != MEMCACHED_SUCCESS)
+ {
+ memcached_io_reset(&ptr->hosts[server_key]);
+ return rc;
+ }
+
+ unlikely((set_data(memc_stat, buffer, buffer + strlen(buffer) + 1)) == MEMCACHED_UNKNOWN_STAT_KEY)
+ {
+ WATCHPOINT_ERROR(MEMCACHED_UNKNOWN_STAT_KEY);
+ WATCHPOINT_ASSERT(0);
+ }
} while (1);
-
+
/* shit... memcached_response will decrement the counter, so I need to
- ** reset it.. todo: look at this and try to find a better solution.
- */
+ ** reset it.. todo: look at this and try to find a better solution.
+ */
ptr->hosts[server_key].cursor_active= 0;
return MEMCACHED_SUCCESS;
}
-static memcached_return ascii_stats_fetch(memcached_st *ptr,
- memcached_stat_st *memc_stat,
- char *args,
- unsigned int server_key)
+static memcached_return_t ascii_stats_fetch(memcached_st *ptr,
+ memcached_stat_st *memc_stat,
+ char *args,
+ unsigned int server_key)
{
- memcached_return rc;
+ memcached_return_t rc;
char buffer[MEMCACHED_DEFAULT_COMMAND_SIZE];
size_t send_length;
rc= memcached_do(&ptr->hosts[server_key], buffer, send_length, 1);
if (rc != MEMCACHED_SUCCESS)
- goto error;
+ goto error;
while (1)
{
return rc;
}
-memcached_stat_st *memcached_stat(memcached_st *ptr, char *args, memcached_return *error)
+memcached_stat_st *memcached_stat(memcached_st *ptr, char *args, memcached_return_t *error)
{
unsigned int x;
- memcached_return rc;
+ memcached_return_t rc;
memcached_stat_st *stats;
unlikely (ptr->flags.use_udp)
rc= MEMCACHED_SUCCESS;
for (x= 0; x < ptr->number_of_hosts; x++)
{
- memcached_return temp_return;
-
+ memcached_return_t temp_return;
+
if (ptr->flags.binary_protocol)
temp_return= binary_stats_fetch(ptr, stats + x, args, x);
else
temp_return= ascii_stats_fetch(ptr, stats + x, args, x);
-
+
if (temp_return != MEMCACHED_SUCCESS)
rc= MEMCACHED_SOME_ERRORS;
}
return stats;
}
-memcached_return memcached_stat_servername(memcached_stat_st *memc_stat, char *args,
- char *hostname, unsigned int port)
+memcached_return_t memcached_stat_servername(memcached_stat_st *memc_stat, char *args,
+ const char *hostname, in_port_t port)
{
- memcached_return rc;
+ memcached_return_t rc;
memcached_st memc;
memcached_st *memc_ptr;
we will add support for "found" keys.
*/
char ** memcached_stat_get_keys(memcached_st *ptr, memcached_stat_st *memc_stat,
- memcached_return *error)
+ memcached_return_t *error)
{
(void) memc_stat;
char **list;
PREPEND_OP,
APPEND_OP,
CAS_OP,
-} memcached_storage_action;
+} memcached_storage_action_t;
/* Inline this */
-static const char *storage_op_string(memcached_storage_action verb)
+static inline const char *storage_op_string(memcached_storage_action_t verb)
{
switch (verb)
{
/* NOTREACHED */
}
-static memcached_return memcached_send_binary(memcached_st *ptr,
- const char *master_key,
- size_t master_key_length,
- const char *key,
- size_t key_length,
- const char *value,
- size_t value_length,
- time_t expiration,
- uint32_t flags,
- uint64_t cas,
- memcached_storage_action verb);
-
-static inline memcached_return memcached_send(memcached_st *ptr,
- const char *master_key, size_t master_key_length,
- const char *key, size_t key_length,
- const char *value, size_t value_length,
- time_t expiration,
- uint32_t flags,
- uint64_t cas,
- memcached_storage_action verb)
+static memcached_return_t memcached_send_binary(memcached_st *ptr,
+ const char *master_key,
+ size_t master_key_length,
+ const char *key,
+ size_t key_length,
+ const char *value,
+ size_t value_length,
+ time_t expiration,
+ uint32_t flags,
+ uint64_t cas,
+ memcached_storage_action_t verb);
+
+static inline memcached_return_t memcached_send(memcached_st *ptr,
+ const char *master_key, size_t master_key_length,
+ const char *key, size_t key_length,
+ const char *value, size_t value_length,
+ time_t expiration,
+ uint32_t flags,
+ uint64_t cas,
+ memcached_storage_action_t verb)
{
char to_write;
size_t write_length;
ssize_t sent_length;
- memcached_return rc;
+ memcached_return_t rc;
char buffer[MEMCACHED_DEFAULT_COMMAND_SIZE];
unsigned int server_key;
rc= memcached_validate_key_length(key_length, ptr->flags.binary_protocol);
unlikely (rc != MEMCACHED_SUCCESS)
return rc;
-
+
unlikely (ptr->number_of_hosts == 0)
return MEMCACHED_NO_SERVERS;
}
-memcached_return memcached_set(memcached_st *ptr, const char *key, size_t key_length,
- const char *value, size_t value_length,
- time_t expiration,
- uint32_t flags)
+memcached_return_t memcached_set(memcached_st *ptr, const char *key, size_t key_length,
+ const char *value, size_t value_length,
+ time_t expiration,
+ uint32_t flags)
{
- memcached_return rc;
+ memcached_return_t rc;
LIBMEMCACHED_MEMCACHED_SET_START();
rc= memcached_send(ptr, key, key_length,
key, key_length, value, value_length,
return rc;
}
-memcached_return memcached_add(memcached_st *ptr,
- const char *key, size_t key_length,
- const char *value, size_t value_length,
- time_t expiration,
- uint32_t flags)
+memcached_return_t memcached_add(memcached_st *ptr,
+ const char *key, size_t key_length,
+ const char *value, size_t value_length,
+ time_t expiration,
+ uint32_t flags)
{
- memcached_return rc;
+ memcached_return_t rc;
LIBMEMCACHED_MEMCACHED_ADD_START();
rc= memcached_send(ptr, key, key_length,
key, key_length, value, value_length,
return rc;
}
-memcached_return memcached_replace(memcached_st *ptr,
- const char *key, size_t key_length,
- const char *value, size_t value_length,
- time_t expiration,
- uint32_t flags)
+memcached_return_t memcached_replace(memcached_st *ptr,
+ const char *key, size_t key_length,
+ const char *value, size_t value_length,
+ time_t expiration,
+ uint32_t flags)
{
- memcached_return rc;
+ memcached_return_t rc;
LIBMEMCACHED_MEMCACHED_REPLACE_START();
rc= memcached_send(ptr, key, key_length,
key, key_length, value, value_length,
return rc;
}
-memcached_return memcached_prepend(memcached_st *ptr,
- const char *key, size_t key_length,
- const char *value, size_t value_length,
- time_t expiration,
- uint32_t flags)
+memcached_return_t memcached_prepend(memcached_st *ptr,
+ const char *key, size_t key_length,
+ const char *value, size_t value_length,
+ time_t expiration,
+ uint32_t flags)
{
- memcached_return rc;
+ memcached_return_t rc;
rc= memcached_send(ptr, key, key_length,
key, key_length, value, value_length,
expiration, flags, 0, PREPEND_OP);
return rc;
}
-memcached_return memcached_append(memcached_st *ptr,
- const char *key, size_t key_length,
- const char *value, size_t value_length,
- time_t expiration,
- uint32_t flags)
+memcached_return_t memcached_append(memcached_st *ptr,
+ const char *key, size_t key_length,
+ const char *value, size_t value_length,
+ time_t expiration,
+ uint32_t flags)
{
- memcached_return rc;
+ memcached_return_t rc;
rc= memcached_send(ptr, key, key_length,
key, key_length, value, value_length,
expiration, flags, 0, APPEND_OP);
return rc;
}
-memcached_return memcached_cas(memcached_st *ptr,
- const char *key, size_t key_length,
- const char *value, size_t value_length,
- time_t expiration,
- uint32_t flags,
- uint64_t cas)
+memcached_return_t memcached_cas(memcached_st *ptr,
+ const char *key, size_t key_length,
+ const char *value, size_t value_length,
+ time_t expiration,
+ uint32_t flags,
+ uint64_t cas)
{
- memcached_return rc;
+ memcached_return_t rc;
rc= memcached_send(ptr, key, key_length,
key, key_length, value, value_length,
expiration, flags, cas, CAS_OP);
return rc;
}
-memcached_return memcached_set_by_key(memcached_st *ptr,
- const char *master_key __attribute__((unused)),
- size_t master_key_length __attribute__((unused)),
- const char *key, size_t key_length,
- const char *value, size_t value_length,
- time_t expiration,
- uint32_t flags)
+memcached_return_t memcached_set_by_key(memcached_st *ptr,
+ const char *master_key __attribute__((unused)),
+ size_t master_key_length __attribute__((unused)),
+ const char *key, size_t key_length,
+ const char *value, size_t value_length,
+ time_t expiration,
+ uint32_t flags)
{
- memcached_return rc;
+ memcached_return_t rc;
LIBMEMCACHED_MEMCACHED_SET_START();
rc= memcached_send(ptr, master_key, master_key_length,
key, key_length, value, value_length,
return rc;
}
-memcached_return memcached_add_by_key(memcached_st *ptr,
- const char *master_key, size_t master_key_length,
- const char *key, size_t key_length,
- const char *value, size_t value_length,
- time_t expiration,
- uint32_t flags)
+memcached_return_t memcached_add_by_key(memcached_st *ptr,
+ const char *master_key, size_t master_key_length,
+ const char *key, size_t key_length,
+ const char *value, size_t value_length,
+ time_t expiration,
+ uint32_t flags)
{
- memcached_return rc;
+ memcached_return_t rc;
LIBMEMCACHED_MEMCACHED_ADD_START();
rc= memcached_send(ptr, master_key, master_key_length,
key, key_length, value, value_length,
return rc;
}
-memcached_return memcached_replace_by_key(memcached_st *ptr,
- const char *master_key, size_t master_key_length,
- const char *key, size_t key_length,
- const char *value, size_t value_length,
- time_t expiration,
- uint32_t flags)
+memcached_return_t memcached_replace_by_key(memcached_st *ptr,
+ const char *master_key, size_t master_key_length,
+ const char *key, size_t key_length,
+ const char *value, size_t value_length,
+ time_t expiration,
+ uint32_t flags)
{
- memcached_return rc;
+ memcached_return_t rc;
LIBMEMCACHED_MEMCACHED_REPLACE_START();
rc= memcached_send(ptr, master_key, master_key_length,
key, key_length, value, value_length,
return rc;
}
-memcached_return memcached_prepend_by_key(memcached_st *ptr,
- const char *master_key, size_t master_key_length,
- const char *key, size_t key_length,
- const char *value, size_t value_length,
- time_t expiration,
- uint32_t flags)
+memcached_return_t memcached_prepend_by_key(memcached_st *ptr,
+ const char *master_key, size_t master_key_length,
+ const char *key, size_t key_length,
+ const char *value, size_t value_length,
+ time_t expiration,
+ uint32_t flags)
{
- memcached_return rc;
+ memcached_return_t rc;
rc= memcached_send(ptr, master_key, master_key_length,
key, key_length, value, value_length,
expiration, flags, 0, PREPEND_OP);
return rc;
}
-memcached_return memcached_append_by_key(memcached_st *ptr,
- const char *master_key, size_t master_key_length,
- const char *key, size_t key_length,
- const char *value, size_t value_length,
- time_t expiration,
- uint32_t flags)
+memcached_return_t memcached_append_by_key(memcached_st *ptr,
+ const char *master_key, size_t master_key_length,
+ const char *key, size_t key_length,
+ const char *value, size_t value_length,
+ time_t expiration,
+ uint32_t flags)
{
- memcached_return rc;
+ memcached_return_t rc;
rc= memcached_send(ptr, master_key, master_key_length,
key, key_length, value, value_length,
expiration, flags, 0, APPEND_OP);
return rc;
}
-memcached_return memcached_cas_by_key(memcached_st *ptr,
- const char *master_key, size_t master_key_length,
- const char *key, size_t key_length,
- const char *value, size_t value_length,
- time_t expiration,
- uint32_t flags,
- uint64_t cas)
+memcached_return_t memcached_cas_by_key(memcached_st *ptr,
+ const char *master_key, size_t master_key_length,
+ const char *key, size_t key_length,
+ const char *value, size_t value_length,
+ time_t expiration,
+ uint32_t flags,
+ uint64_t cas)
{
- memcached_return rc;
+ memcached_return_t rc;
rc= memcached_send(ptr, master_key, master_key_length,
key, key_length, value, value_length,
expiration, flags, cas, CAS_OP);
return rc;
}
-static inline uint8_t get_com_code(memcached_storage_action verb, bool noreply)
+static inline uint8_t get_com_code(memcached_storage_action_t verb, bool noreply)
{
/* 0 isn't a value we want, but GCC 4.2 seems to think ret can otherwise
* be used uninitialized in this function. FAIL */
break;
}
- return ret;
+ return ret;
}
-static memcached_return memcached_send_binary(memcached_st *ptr,
- const char *master_key,
- size_t master_key_length,
- const char *key,
- size_t key_length,
- const char *value,
- size_t value_length,
- time_t expiration,
- uint32_t flags,
- uint64_t cas,
- memcached_storage_action verb)
+static memcached_return_t memcached_send_binary(memcached_st *ptr,
+ const char *master_key,
+ size_t master_key_length,
+ const char *key,
+ size_t key_length,
+ const char *value,
+ size_t value_length,
+ time_t expiration,
+ uint32_t flags,
+ uint64_t cas,
+ memcached_storage_action_t verb)
{
uint8_t flush;
protocol_binary_request_set request= {.bytes= {0}};
request.message.body.flags= htonl(flags);
request.message.body.expiration= htonl((uint32_t)expiration);
}
-
+
request.message.header.request.bodylen= htonl((uint32_t) (key_length + value_length +
- request.message.header.request.extlen));
-
+ request.message.header.request.extlen));
+
if (cas)
request.message.header.request.cas= htonll(cas);
-
+
flush= (uint8_t) ((server->root->flags.buffer_requests && verb == SET_OP) ? 0 : 1);
if (server->root->flags.use_udp && !flush)
if (cmd_size + server->write_buffer_offset > MAX_UDP_DATAGRAM_LENGTH)
memcached_io_write(server,NULL,0, 1);
}
-
+
/* write the header */
if ((memcached_do(server, (const char*)request.bytes, send_length, 0) != MEMCACHED_SUCCESS) ||
(memcached_io_write(server, key, key_length, 0) == -1) ||
/* All of the functions for adding data to the server */
LIBMEMCACHED_API
-memcached_return memcached_set(memcached_st *ptr, const char *key, size_t key_length,
- const char *value, size_t value_length,
- time_t expiration,
- uint32_t flags);
+memcached_return_t memcached_set(memcached_st *ptr, const char *key, size_t key_length,
+ const char *value, size_t value_length,
+ time_t expiration,
+ uint32_t flags);
LIBMEMCACHED_API
-memcached_return memcached_add(memcached_st *ptr, const char *key, size_t key_length,
- const char *value, size_t value_length,
- time_t expiration,
- uint32_t flags);
+memcached_return_t memcached_add(memcached_st *ptr, const char *key, size_t key_length,
+ const char *value, size_t value_length,
+ time_t expiration,
+ uint32_t flags);
LIBMEMCACHED_API
-memcached_return memcached_replace(memcached_st *ptr, const char *key, size_t key_length,
- const char *value, size_t value_length,
- time_t expiration,
- uint32_t flags);
+memcached_return_t memcached_replace(memcached_st *ptr, const char *key, size_t key_length,
+ const char *value, size_t value_length,
+ time_t expiration,
+ uint32_t flags);
LIBMEMCACHED_API
-memcached_return memcached_append(memcached_st *ptr,
- const char *key, size_t key_length,
- const char *value, size_t value_length,
- time_t expiration,
- uint32_t flags);
+memcached_return_t memcached_append(memcached_st *ptr,
+ const char *key, size_t key_length,
+ const char *value, size_t value_length,
+ time_t expiration,
+ uint32_t flags);
LIBMEMCACHED_API
-memcached_return memcached_prepend(memcached_st *ptr,
- const char *key, size_t key_length,
- const char *value, size_t value_length,
- time_t expiration,
- uint32_t flags);
+memcached_return_t memcached_prepend(memcached_st *ptr,
+ const char *key, size_t key_length,
+ const char *value, size_t value_length,
+ time_t expiration,
+ uint32_t flags);
LIBMEMCACHED_API
-memcached_return memcached_cas(memcached_st *ptr,
- const char *key, size_t key_length,
- const char *value, size_t value_length,
- time_t expiration,
- uint32_t flags,
- uint64_t cas);
+memcached_return_t memcached_cas(memcached_st *ptr,
+ const char *key, size_t key_length,
+ const char *value, size_t value_length,
+ time_t expiration,
+ uint32_t flags,
+ uint64_t cas);
LIBMEMCACHED_API
-memcached_return memcached_set_by_key(memcached_st *ptr,
- const char *master_key, size_t master_key_length,
- const char *key, size_t key_length,
- const char *value, size_t value_length,
- time_t expiration,
- uint32_t flags);
+memcached_return_t memcached_set_by_key(memcached_st *ptr,
+ const char *master_key, size_t master_key_length,
+ const char *key, size_t key_length,
+ const char *value, size_t value_length,
+ time_t expiration,
+ uint32_t flags);
LIBMEMCACHED_API
-memcached_return memcached_add_by_key(memcached_st *ptr,
- const char *master_key, size_t master_key_length,
- const char *key, size_t key_length,
- const char *value, size_t value_length,
- time_t expiration,
- uint32_t flags);
+memcached_return_t memcached_add_by_key(memcached_st *ptr,
+ const char *master_key, size_t master_key_length,
+ const char *key, size_t key_length,
+ const char *value, size_t value_length,
+ time_t expiration,
+ uint32_t flags);
LIBMEMCACHED_API
-memcached_return memcached_replace_by_key(memcached_st *ptr,
- const char *master_key, size_t master_key_length,
- const char *key, size_t key_length,
- const char *value, size_t value_length,
- time_t expiration,
- uint32_t flags);
+memcached_return_t memcached_replace_by_key(memcached_st *ptr,
+ const char *master_key, size_t master_key_length,
+ const char *key, size_t key_length,
+ const char *value, size_t value_length,
+ time_t expiration,
+ uint32_t flags);
LIBMEMCACHED_API
-memcached_return memcached_prepend_by_key(memcached_st *ptr,
- const char *master_key, size_t master_key_length,
- const char *key, size_t key_length,
- const char *value, size_t value_length,
- time_t expiration,
- uint32_t flags);
+memcached_return_t memcached_prepend_by_key(memcached_st *ptr,
+ const char *master_key, size_t master_key_length,
+ const char *key, size_t key_length,
+ const char *value, size_t value_length,
+ time_t expiration,
+ uint32_t flags);
LIBMEMCACHED_API
-memcached_return memcached_append_by_key(memcached_st *ptr,
- const char *master_key, size_t master_key_length,
- const char *key, size_t key_length,
- const char *value, size_t value_length,
- time_t expiration,
- uint32_t flags);
+memcached_return_t memcached_append_by_key(memcached_st *ptr,
+ const char *master_key, size_t master_key_length,
+ const char *key, size_t key_length,
+ const char *value, size_t value_length,
+ time_t expiration,
+ uint32_t flags);
LIBMEMCACHED_API
-memcached_return memcached_cas_by_key(memcached_st *ptr,
- const char *master_key, size_t master_key_length,
- const char *key, size_t key_length,
- const char *value, size_t value_length,
- time_t expiration,
- uint32_t flags,
- uint64_t cas);
+memcached_return_t memcached_cas_by_key(memcached_st *ptr,
+ const char *master_key, size_t master_key_length,
+ const char *key, size_t key_length,
+ const char *value, size_t value_length,
+ time_t expiration,
+ uint32_t flags,
+ uint64_t cas);
#ifdef __cplusplus
}
#include "common.h"
-const char *memcached_strerror(memcached_st *ptr __attribute__((unused)), memcached_return rc)
+const char *memcached_strerror(memcached_st *ptr __attribute__((unused)), memcached_return_t rc)
{
switch (rc)
{
+/* LibMemcached
+ * Copyright (C) 2006-2009 Brian Aker
+ * All rights reserved.
+ *
+ * Use and distribution licensed under the BSD license. See
+ * the COPYING file in the parent directory for full text.
+ *
+ */
+
#include "common.h"
-inline static memcached_return _string_check(memcached_string_st *string, size_t need)
+inline static memcached_return_t _string_check(memcached_string_st *string, size_t need)
{
if (need && need > (size_t)(string->current_size - (size_t)(string->end - string->string)))
{
memcached_string_st *memcached_string_create(memcached_st *memc, memcached_string_st *string, size_t initial_size)
{
- memcached_return rc;
+ memcached_return_t rc;
/* Saving malloc calls :) */
if (string)
return string;
}
-memcached_return memcached_string_append_character(memcached_string_st *string,
+memcached_return_t memcached_string_append_character(memcached_string_st *string,
char character)
{
- memcached_return rc;
+ memcached_return_t rc;
rc= _string_check(string, 1);
return MEMCACHED_SUCCESS;
}
-memcached_return memcached_string_append(memcached_string_st *string,
+memcached_return_t memcached_string_append(memcached_string_st *string,
const char *value, size_t length)
{
- memcached_return rc;
+ memcached_return_t rc;
rc= _string_check(string, length);
return c_ptr;
}
-memcached_return memcached_string_reset(memcached_string_st *string)
+memcached_return_t memcached_string_reset(memcached_string_st *string)
{
string->end= string->string;
}
}
-memcached_return memcached_string_check(memcached_string_st *string, size_t need)
+memcached_return_t memcached_string_check(memcached_string_st *string, size_t need)
{
return _string_check(string, need);
}
-/*
- * Summary: String structure used for libmemcached.
+/* LibMemcached
+ * Copyright (C) 2006-2009 Brian Aker
+ * All rights reserved.
+ *
+ * Use and distribution licensed under the BSD license. See
+ * the COPYING file in the parent directory for full text.
*
- * Copy: See Copyright for the status of this software.
+ * Summary: String structure used for libmemcached.
*
- * Author: Brian Aker
*/
#ifndef __MEMCACHED_STRING_H__
memcached_string_st *string,
size_t initial_size);
LIBMEMCACHED_API
-memcached_return memcached_string_check(memcached_string_st *string, size_t need);
+memcached_return_t memcached_string_check(memcached_string_st *string, size_t need);
LIBMEMCACHED_API
char *memcached_string_c_copy(memcached_string_st *string);
LIBMEMCACHED_API
-memcached_return memcached_string_append_character(memcached_string_st *string,
- char character);
+memcached_return_t memcached_string_append_character(memcached_string_st *string,
+ char character);
LIBMEMCACHED_API
-memcached_return memcached_string_append(memcached_string_st *string,
- const char *value, size_t length);
+memcached_return_t memcached_string_append(memcached_string_st *string,
+ const char *value, size_t length);
LIBMEMCACHED_API
-memcached_return memcached_string_reset(memcached_string_st *string);
+memcached_return_t memcached_string_reset(memcached_string_st *string);
LIBMEMCACHED_API
void memcached_string_free(memcached_string_st *string);
-/*
- * Summary: Typpes for libmemcached
+/* LibMemcached
+ * Copyright (C) 2006-2009 Brian Aker
+ * All rights reserved.
*
- * Copy: See Copyright for the status of this software.
+ * Use and distribution licensed under the BSD license. See
+ * the COPYING file in the parent directory for full text.
+ *
+ * Summary: Types for libmemcached
*
- * Author: Brian Aker
*/
#ifndef LIBMEMCACHED_MEMCACHED_TYPES_H
typedef struct memcached_string_st memcached_string_st;
typedef struct memcached_server_st memcached_server_st;
typedef struct memcached_continuum_item_st memcached_continuum_item_st;
-typedef memcached_return (*memcached_clone_func)(memcached_st *parent, memcached_st *clone);
-typedef memcached_return (*memcached_cleanup_func)(memcached_st *ptr);
-typedef void (*memcached_free_function)(memcached_st *ptr, void *mem);
-typedef void *(*memcached_malloc_function)(memcached_st *ptr, const size_t size);
-typedef void *(*memcached_realloc_function)(memcached_st *ptr, void *mem, const size_t size);
-typedef void *(*memcached_calloc_function)(memcached_st *ptr, size_t nelem, const size_t elsize);
-typedef memcached_return (*memcached_execute_function)(memcached_st *ptr, memcached_result_st *result, void *context);
-typedef memcached_return (*memcached_server_function)(memcached_st *ptr, memcached_server_st *server, void *context);
-typedef memcached_return (*memcached_trigger_key)(memcached_st *ptr,
- const char *key, size_t key_length,
- memcached_result_st *result);
-typedef memcached_return (*memcached_trigger_delete_key)(memcached_st *ptr,
- const char *key, size_t key_length);
-
-typedef memcached_return (*memcached_dump_func)(memcached_st *ptr,
- const char *key, size_t key_length, void *context);
+typedef memcached_return_t (*memcached_clone_fn)(memcached_st *parent, memcached_st *clone);
+typedef memcached_return_t (*memcached_cleanup_fn)(memcached_st *ptr);
+typedef void (*memcached_free_fn)(memcached_st *ptr, void *mem);
+typedef void *(*memcached_malloc_fn)(memcached_st *ptr, const size_t size);
+typedef void *(*memcached_realloc_fn)(memcached_st *ptr, void *mem, const size_t size);
+typedef void *(*memcached_calloc_fn)(memcached_st *ptr, size_t nelem, const size_t elsize);
+typedef memcached_return_t (*memcached_execute_fn)(memcached_st *ptr, memcached_result_st *result, void *context);
+typedef memcached_return_t (*memcached_server_fn)(memcached_st *ptr, memcached_server_st *server, void *context);
+typedef memcached_return_t (*memcached_trigger_key_fn)(memcached_st *ptr,
+ const char *key, size_t key_length,
+ memcached_result_st *result);
+typedef memcached_return_t (*memcached_trigger_delete_key_fn)(memcached_st *ptr,
+ const char *key, size_t key_length);
+
+typedef memcached_return_t (*memcached_dump_fn)(memcached_st *ptr,
+ const char *key, size_t key_length, void *context);
typedef struct {
- memcached_execute_function *callback;
+ memcached_execute_fn *callback;
void *context;
- unsigned int number_of_callback;
+ uint32_t number_of_callback;
} memcached_callback_st;
+
+/**
+ @note The following definitions are just here for backwards compatibility.
+*/
+typedef memcached_return_t memcached_return;
+typedef memcached_server_distribution_t memcached_server_distribution;
+typedef memcached_behavior_t memcached_behavior;
+typedef memcached_callback_t memcached_callback;
+typedef memcached_hash_t memcached_hash;
+typedef memcached_connection_t memcached_connection;
+typedef memcached_clone_fn memcached_clone_func;
+typedef memcached_cleanup_fn memcached_cleanup_func;
+typedef memcached_free_fn memcached_free_function;
+typedef memcached_malloc_fn memcached_malloc_function;
+typedef memcached_realloc_fn memcached_realloc_function;
+typedef memcached_calloc_fn memcached_calloc_function;
+typedef memcached_execute_fn memcached_execute_function;
+typedef memcached_server_fn memcached_server_function;
+typedef memcached_trigger_key_fn memcached_trigger_key;
+typedef memcached_trigger_delete_key_fn memcached_trigger_delete_key;
+typedef memcached_dump_fn memcached_dump_func;
+
+
#ifdef __cplusplus
}
#endif
#include "common.h"
-memcached_return memcached_verbosity(memcached_st *ptr, unsigned int verbosity)
+memcached_return_t memcached_verbosity(memcached_st *ptr, unsigned int verbosity)
{
unsigned int x;
size_t send_length;
- memcached_return rc;
+ memcached_return_t rc;
char buffer[MEMCACHED_DEFAULT_COMMAND_SIZE];
send_length= (size_t) snprintf(buffer, MEMCACHED_DEFAULT_COMMAND_SIZE,
rc= MEMCACHED_SUCCESS;
for (x= 0; x < ptr->number_of_hosts; x++)
{
- memcached_return rrc;
+ memcached_return_t rrc;
rrc= memcached_do(&ptr->hosts[x], buffer, send_length, 1);
if (rrc != MEMCACHED_SUCCESS)
return LIBMEMCACHED_VERSION_STRING;
}
-static inline memcached_return memcached_version_binary(memcached_st *ptr);
-static inline memcached_return memcached_version_textual(memcached_st *ptr);
+static inline memcached_return_t memcached_version_binary(memcached_st *ptr);
+static inline memcached_return_t memcached_version_textual(memcached_st *ptr);
-memcached_return memcached_version(memcached_st *ptr)
+memcached_return_t memcached_version(memcached_st *ptr)
{
- if (ptr->flags.use_udp)
+ if (ptr->flags.use_udp)
return MEMCACHED_NOT_SUPPORTED;
- if (ptr->flags.binary_protocol)
- return memcached_version_binary(ptr);
- else
- return memcached_version_textual(ptr);
+ if (ptr->flags.binary_protocol)
+ return memcached_version_binary(ptr);
+ else
+ return memcached_version_textual(ptr);
}
-static inline memcached_return memcached_version_textual(memcached_st *ptr)
+static inline memcached_return_t memcached_version_textual(memcached_st *ptr)
{
unsigned int x;
size_t send_length;
- memcached_return rc;
+ memcached_return_t rc;
char buffer[MEMCACHED_DEFAULT_COMMAND_SIZE];
char *response_ptr;
const char *command= "version\r\n";
rc= MEMCACHED_SUCCESS;
for (x= 0; x < ptr->number_of_hosts; x++)
{
- memcached_return rrc;
+ memcached_return_t rrc;
rrc= memcached_do(&ptr->hosts[x], command, send_length, 1);
if (rrc != MEMCACHED_SUCCESS)
return rc;
}
-static inline memcached_return memcached_version_binary(memcached_st *ptr)
+static inline memcached_return_t memcached_version_binary(memcached_st *ptr)
{
- memcached_return rc;
+ memcached_return_t rc;
unsigned int x;
protocol_binary_request_version request= { .bytes= {0}};
request.message.header.request.magic= PROTOCOL_BINARY_REQ;
rc= MEMCACHED_SUCCESS;
for (x= 0; x < ptr->number_of_hosts; x++)
{
- memcached_return rrc;
+ memcached_return_t rrc;
rrc= memcached_do(&ptr->hosts[x], request.bytes, sizeof(request.bytes), 1);
if (rrc != MEMCACHED_SUCCESS)
for (x= 0; x < ptr->number_of_hosts; x++)
if (memcached_server_response_count(&ptr->hosts[x]) > 0)
{
- memcached_return rrc;
+ memcached_return_t rrc;
char buffer[32];
char *p;
int firstfree;
uint32_t size;
uint32_t current_size;
- char* version;
+ char *version;
};
-static memcached_return mutex_enter(pthread_mutex_t *mutex)
+static memcached_return_t mutex_enter(pthread_mutex_t *mutex)
{
int ret;
do
return (ret == -1) ? MEMCACHED_ERRNO : MEMCACHED_SUCCESS;
}
-static memcached_return mutex_exit(pthread_mutex_t *mutex) {
+static memcached_return_t mutex_exit(pthread_mutex_t *mutex) {
int ret;
do
ret= pthread_mutex_unlock(mutex);
{
memcached_pool_st* ret = NULL;
memcached_pool_st object = { .mutex = PTHREAD_MUTEX_INITIALIZER,
- .cond = PTHREAD_COND_INITIALIZER,
- .master = mmc,
- .mmc = calloc(max, sizeof(memcached_st*)),
- .firstfree = -1,
- .size = max,
- .current_size = 0 };
+ .cond = PTHREAD_COND_INITIALIZER,
+ .master = mmc,
+ .mmc = calloc(max, sizeof(memcached_st*)),
+ .firstfree = -1,
+ .size = max,
+ .current_size = 0 };
if (object.mmc != NULL)
{
/* Try to create the initial size of the pool. An allocation failure at
* this time is not fatal..
- */
+ */
for (unsigned int ii=0; ii < initial; ++ii)
if (grow_pool(ret) == -1)
break;
free(pool->mmc[xx]);
pool->mmc[xx] = NULL;
}
-
+
pthread_mutex_destroy(&pool->mutex);
pthread_cond_destroy(&pool->cond);
free(pool->mmc);
memcached_st* memcached_pool_pop(memcached_pool_st* pool,
bool block,
- memcached_return *rc)
+ memcached_return_t *rc)
{
memcached_st *ret= NULL;
if ((*rc= mutex_enter(&pool->mutex)) != MEMCACHED_SUCCESS)
do
{
if (pool->firstfree > -1)
- ret= pool->mmc[pool->firstfree--];
+ ret= pool->mmc[pool->firstfree--];
else if (pool->current_size == pool->size)
{
if (!block)
}
else if (grow_pool(pool) == -1)
{
- *rc= mutex_exit(&pool->mutex);
- return NULL;
+ *rc= mutex_exit(&pool->mutex);
+ return NULL;
}
}
while (ret == NULL);
return ret;
}
-memcached_return memcached_pool_push(memcached_pool_st* pool,
- memcached_st *mmc)
+memcached_return_t memcached_pool_push(memcached_pool_st* pool,
+ memcached_st *mmc)
{
- memcached_return rc= mutex_enter(&pool->mutex);
+ memcached_return_t rc= mutex_enter(&pool->mutex);
if (rc != MEMCACHED_SUCCESS)
return rc;
pthread_cond_broadcast(&pool->cond);
}
- memcached_return rval= mutex_exit(&pool->mutex);
+ memcached_return_t rval= mutex_exit(&pool->mutex);
if (rc == MEMCACHED_SOME_ERRORS)
return rc;
}
-memcached_return memcached_pool_behavior_set(memcached_pool_st *pool,
- memcached_behavior flag,
- uint64_t data)
+memcached_return_t memcached_pool_behavior_set(memcached_pool_st *pool,
+ memcached_behavior_t flag,
+ uint64_t data)
{
- memcached_return rc= mutex_enter(&pool->mutex);
+ memcached_return_t rc= mutex_enter(&pool->mutex);
if (rc != MEMCACHED_SUCCESS)
- return rc;
+ return rc;
/* update the master */
rc= memcached_behavior_set(pool->master, flag, data);
if (memcached_clone(pool->mmc[xx], pool->master) == NULL)
{
/* I'm not sure what to do in this case.. this would happen
- if we fail to push the server list inside the client..
- I should add a testcase for this, but I believe the following
- would work, except that you would add a hole in the pool list..
- in theory you could end up with an empty pool....
+ if we fail to push the server list inside the client..
+ I should add a testcase for this, but I believe the following
+ would work, except that you would add a hole in the pool list..
+ in theory you could end up with an empty pool....
*/
free(pool->mmc[xx]);
pool->mmc[xx]= NULL;
return mutex_exit(&pool->mutex);
}
-memcached_return memcached_pool_behavior_get(memcached_pool_st *pool,
- memcached_behavior flag,
- uint64_t *value)
+memcached_return_t memcached_pool_behavior_get(memcached_pool_st *pool,
+ memcached_behavior_t flag,
+ uint64_t *value)
{
- memcached_return rc= mutex_enter(&pool->mutex);
+ memcached_return_t rc= mutex_enter(&pool->mutex);
if (rc != MEMCACHED_SUCCESS)
return rc;
*value= memcached_behavior_get(pool->master, flag);
static test_return_t drizzle(memcached_st *memc)
{
unsigned int x;
- memcached_return rc;
+ memcached_return_t rc;
char *return_value;
size_t return_value_length;
uint32_t flags;
return 0;
}
-static memcached_return pre_nonblock(memcached_st *memc)
+static memcached_return_t pre_nonblock(memcached_st *memc)
{
memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_NO_BLOCK, 0);
return MEMCACHED_SUCCESS;
}
-static memcached_return pre_md5(memcached_st *memc)
+static memcached_return_t pre_md5(memcached_st *memc)
{
memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_HASH, (uint64_t)MEMCACHED_HASH_MD5);
return MEMCACHED_SUCCESS;
}
-static memcached_return pre_hsieh(memcached_st *memc)
+static memcached_return_t pre_hsieh(memcached_st *memc)
{
memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_HASH, (uint64_t)MEMCACHED_HASH_HSIEH);
return MEMCACHED_SUCCESS;
}
-static memcached_return enable_consistent(memcached_st *memc)
+static memcached_return_t enable_consistent(memcached_st *memc)
{
- memcached_server_distribution value= MEMCACHED_DISTRIBUTION_CONSISTENT;
- memcached_hash hash;
+ memcached_server_distribution_t value= MEMCACHED_DISTRIBUTION_CONSISTENT;
+ memcached_hash_t hash;
memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_DISTRIBUTION, value);
pre_hsieh(memc);
- value= (memcached_server_distribution)memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_DISTRIBUTION);
+ value= (memcached_server_distribution_t)memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_DISTRIBUTION);
assert(value == MEMCACHED_DISTRIBUTION_CONSISTENT);
- hash= (memcached_hash)memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_HASH);
+ hash= (memcached_hash_t)memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_HASH);
assert(hash == MEMCACHED_HASH_HSIEH);
*/
static test_return_t add_test(memcached_st *memc)
{
- memcached_return rc;
+ memcached_return_t rc;
const char *key= "foo";
const char *value= "when we sanitize";
unsigned long long setting_value;
static test_return_t server_list_null_test(memcached_st *ptr __attribute__((unused)))
{
memcached_server_st *server_list;
- memcached_return rc;
+ memcached_return_t rc;
server_list= memcached_server_list_append_with_weight(NULL, NULL, 0, 0, NULL);
test_truth(server_list == NULL);
#define TEST_PORT_COUNT 7
uint32_t test_ports[TEST_PORT_COUNT];
-static memcached_return server_display_function(memcached_st *ptr __attribute__((unused)), memcached_server_st *server, void *context)
+static memcached_return_t server_display_function(memcached_st *ptr __attribute__((unused)), memcached_server_st *server, void *context)
{
/* Do Nothing */
uint32_t bigger= *((uint32_t *)(context));
{
uint32_t x;
uint32_t bigger= 0; /* Prime the value for the test_truth in server_display_function */
- memcached_return rc;
- memcached_server_function callbacks[1];
+ memcached_return_t rc;
+ memcached_server_fn callbacks[1];
memcached_st *local_memc;
local_memc= memcached_create(NULL);
static test_return_t server_sort2_test(memcached_st *ptr __attribute__((unused)))
{
uint32_t bigger= 0; /* Prime the value for the test_truth in server_display_function */
- memcached_return rc;
- memcached_server_function callbacks[1];
+ memcached_return_t rc;
+ memcached_server_fn callbacks[1];
memcached_st *local_memc;
local_memc= memcached_create(NULL);
return TEST_SUCCESS;
}
-static memcached_return server_display_unsort_function(memcached_st *ptr __attribute__((unused)), memcached_server_st *server, void *context)
+static memcached_return_t server_display_unsort_function(memcached_st *ptr __attribute__((unused)), memcached_server_st *server, void *context)
{
/* Do Nothing */
uint32_t x= *((uint32_t *)(context));
uint32_t x;
uint32_t counter= 0; /* Prime the value for the test_truth in server_display_function */
uint32_t bigger= 0; /* Prime the value for the test_truth in server_display_function */
- memcached_return rc;
- memcached_server_function callbacks[1];
+ memcached_return_t rc;
+ memcached_server_fn callbacks[1];
memcached_st *local_memc;
local_memc= memcached_create(NULL);
static test_return_t connection_test(memcached_st *memc)
{
- memcached_return rc;
+ memcached_return_t rc;
rc= memcached_server_add_with_weight(memc, "localhost", 0, 0);
test_truth(rc == MEMCACHED_SUCCESS);
static test_return_t error_test(memcached_st *memc)
{
- memcached_return rc;
+ memcached_return_t rc;
uint32_t values[] = { 851992627U, 2337886783U, 3196981036U, 4001849190U,
982370485U, 1263635348U, 4242906218U, 3829656100U,
1891735253U, 334139633U, 2257084983U, 3088286104U,
static test_return_t set_test(memcached_st *memc)
{
- memcached_return rc;
+ memcached_return_t rc;
const char *key= "foo";
const char *value= "when we sanitize";
static test_return_t append_test(memcached_st *memc)
{
- memcached_return rc;
+ memcached_return_t rc;
const char *key= "fig";
const char *in_value= "we";
char *out_value= NULL;
static test_return_t append_binary_test(memcached_st *memc)
{
- memcached_return rc;
+ memcached_return_t rc;
const char *key= "numbers";
unsigned int *store_ptr;
unsigned int store_list[] = { 23, 56, 499, 98, 32847, 0 };
static test_return_t cas2_test(memcached_st *memc)
{
- memcached_return rc;
+ memcached_return_t rc;
const char *keys[]= {"fudge", "son", "food"};
size_t key_length[]= {5, 3, 4};
const char *value= "we the people";
static test_return_t cas_test(memcached_st *memc)
{
- memcached_return rc;
+ memcached_return_t rc;
const char *key= "fun";
size_t key_length= strlen(key);
const char *value= "we the people";
static test_return_t prepend_test(memcached_st *memc)
{
- memcached_return rc;
+ memcached_return_t rc;
const char *key= "fig";
const char *value= "people";
char *out_value= NULL;
*/
static test_return_t add_test(memcached_st *memc)
{
- memcached_return rc;
+ memcached_return_t rc;
const char *key= "foo";
const char *value= "when we sanitize";
unsigned long long setting_value;
static test_return_t replace_test(memcached_st *memc)
{
- memcached_return rc;
+ memcached_return_t rc;
const char *key= "foo";
const char *value= "when we sanitize";
const char *original= "first we insert some data";
static test_return_t delete_test(memcached_st *memc)
{
- memcached_return rc;
+ memcached_return_t rc;
const char *key= "foo";
const char *value= "when we sanitize";
static test_return_t flush_test(memcached_st *memc)
{
- memcached_return rc;
+ memcached_return_t rc;
rc= memcached_flush(memc, 0);
test_truth(rc == MEMCACHED_SUCCESS);
return TEST_SUCCESS;
}
-static memcached_return server_function(memcached_st *ptr __attribute__((unused)),
+static memcached_return_t server_function(memcached_st *ptr __attribute__((unused)),
memcached_server_st *server __attribute__((unused)),
void *context __attribute__((unused)))
{
{
char context[8];
strcpy(context, "foo bad");
- memcached_server_function callbacks[1];
+ memcached_server_fn callbacks[1];
callbacks[0]= server_function;
memcached_server_cursor(memc, callbacks, context, 1);
static test_return_t bad_key_test(memcached_st *memc)
{
- memcached_return rc;
+ memcached_return_t rc;
const char *key= "foo bad";
char *string;
size_t string_length;
}
#define READ_THROUGH_VALUE "set for me"
-static memcached_return read_through_trigger(memcached_st *memc __attribute__((unused)),
+static memcached_return_t read_through_trigger(memcached_st *memc __attribute__((unused)),
char *key __attribute__((unused)),
size_t key_length __attribute__((unused)),
memcached_result_st *result)
static test_return_t read_through(memcached_st *memc)
{
- memcached_return rc;
+ memcached_return_t rc;
const char *key= "foo";
char *string;
size_t string_length;
uint32_t flags;
- memcached_trigger_key cb= (memcached_trigger_key)read_through_trigger;
+ memcached_trigger_key_fn cb= (memcached_trigger_key_fn)read_through_trigger;
string= memcached_get(memc, key, strlen(key),
&string_length, &flags, &rc);
return TEST_SUCCESS;
}
-static memcached_return delete_trigger(memcached_st *ptr __attribute__((unused)),
+static memcached_return_t delete_trigger(memcached_st *ptr __attribute__((unused)),
const char *key,
size_t key_length __attribute__((unused)))
{
static test_return_t delete_through(memcached_st *memc)
{
- memcached_trigger_delete_key callback;
- memcached_return rc;
+ memcached_trigger_delete_key_fn callback;
+ memcached_return_t rc;
- callback= (memcached_trigger_delete_key)delete_trigger;
+ callback= (memcached_trigger_delete_key_fn)delete_trigger;
rc= memcached_callback_set(memc, MEMCACHED_CALLBACK_DELETE_TRIGGER, *(void**)&callback);
test_truth(rc == MEMCACHED_SUCCESS);
static test_return_t get_test(memcached_st *memc)
{
- memcached_return rc;
+ memcached_return_t rc;
const char *key= "foo";
char *string;
size_t string_length;
static test_return_t get_test2(memcached_st *memc)
{
- memcached_return rc;
+ memcached_return_t rc;
const char *key= "foo";
const char *value= "when we sanitize";
char *string;
static test_return_t set_test2(memcached_st *memc)
{
- memcached_return rc;
+ memcached_return_t rc;
const char *key= "foo";
const char *value= "train in the brain";
size_t value_length= strlen(value);
static test_return_t set_test3(memcached_st *memc)
{
- memcached_return rc;
+ memcached_return_t rc;
char *value;
size_t value_length= 8191;
unsigned int x;
static test_return_t get_test3(memcached_st *memc)
{
- memcached_return rc;
+ memcached_return_t rc;
const char *key= "foo";
char *value;
size_t value_length= 8191;
static test_return_t get_test4(memcached_st *memc)
{
- memcached_return rc;
+ memcached_return_t rc;
const char *key= "foo";
char *value;
size_t value_length= 8191;
uint32_t flags;
size_t rlen;
- memcached_return rc= memcached_set(memc, keys[0], lengths[0],
+ memcached_return_t rc= memcached_set(memc, keys[0], lengths[0],
keys[0], lengths[0], 0, 0);
test_truth(rc == MEMCACHED_SUCCESS);
rc= memcached_mget(memc, keys, lengths, 2);
size_t lengths[]= { 3, 4 };
const char *values[]= { "fjord", "41" };
- memcached_return rc;
+ memcached_return_t rc;
// Set foo and foo2
for (int i= 0; i < 2; i++)
/* Do not copy the style of this code, I just access hosts to testthis function */
static test_return_t stats_servername_test(memcached_st *memc)
{
- memcached_return rc;
+ memcached_return_t rc;
memcached_stat_st memc_stat;
rc= memcached_stat_servername(&memc_stat, NULL,
memc->hosts[0].hostname,
static test_return_t increment_test(memcached_st *memc)
{
uint64_t new_number;
- memcached_return rc;
+ memcached_return_t rc;
const char *key= "number";
const char *value= "0";
if (memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL) != 0)
{
uint64_t new_number;
- memcached_return rc;
+ memcached_return_t rc;
const char *key= "number";
uint64_t initial= 0;
static test_return_t decrement_test(memcached_st *memc)
{
uint64_t new_number;
- memcached_return rc;
+ memcached_return_t rc;
const char *key= "number";
const char *value= "3";
if (memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL) != 0)
{
uint64_t new_number;
- memcached_return rc;
+ memcached_return_t rc;
const char *key= "number";
uint64_t initial= 3;
static test_return_t increment_by_key_test(memcached_st *memc)
{
uint64_t new_number;
- memcached_return rc;
+ memcached_return_t rc;
const char *master_key= "foo";
const char *key= "number";
const char *value= "0";
if (memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL) != 0)
{
uint64_t new_number;
- memcached_return rc;
+ memcached_return_t rc;
const char *master_key= "foo";
const char *key= "number";
uint64_t initial= 0;
static test_return_t decrement_by_key_test(memcached_st *memc)
{
uint64_t new_number;
- memcached_return rc;
+ memcached_return_t rc;
const char *master_key= "foo";
const char *key= "number";
const char *value= "3";
if (memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL) != 0)
{
uint64_t new_number;
- memcached_return rc;
+ memcached_return_t rc;
const char *master_key= "foo";
const char *key= "number";
uint64_t initial= 3;
static test_return_t quit_test(memcached_st *memc)
{
- memcached_return rc;
+ memcached_return_t rc;
const char *key= "fudge";
const char *value= "sanford and sun";
static test_return_t mget_result_test(memcached_st *memc)
{
- memcached_return rc;
+ memcached_return_t rc;
const char *keys[]= {"fudge", "son", "food"};
size_t key_length[]= {5, 3, 4};
unsigned int x;
static test_return_t mget_result_alloc_test(memcached_st *memc)
{
- memcached_return rc;
+ memcached_return_t rc;
const char *keys[]= {"fudge", "son", "food"};
size_t key_length[]= {5, 3, 4};
unsigned int x;
}
/* Count the results */
-static memcached_return callback_counter(memcached_st *ptr __attribute__((unused)),
+static memcached_return_t callback_counter(memcached_st *ptr __attribute__((unused)),
memcached_result_st *result __attribute__((unused)),
void *context)
{
static test_return_t mget_result_function(memcached_st *memc)
{
- memcached_return rc;
+ memcached_return_t rc;
const char *keys[]= {"fudge", "son", "food"};
size_t key_length[]= {5, 3, 4};
unsigned int x;
unsigned int counter;
- memcached_execute_function callbacks[1];
+ memcached_execute_fn callbacks[1];
/* We need to empty the server before continueing test */
rc= memcached_flush(memc, 0);
static test_return_t mget_test(memcached_st *memc)
{
- memcached_return rc;
+ memcached_return_t rc;
const char *keys[]= {"fudge", "son", "food"};
size_t key_length[]= {5, 3, 4};
unsigned int x;
/* First add all of the items.. */
char blob[1024] = {0};
- memcached_return rc;
+ memcached_return_t rc;
for (int x= 0; x < max_keys; ++x)
{
char k[251];
/* Try to get all of them with a large multiget */
unsigned int counter= 0;
- memcached_execute_function callbacks[1]= { [0]= &callback_counter };
+ memcached_execute_fn callbacks[1]= { [0]= &callback_counter };
rc= memcached_mget_execute(memc, (const char**)keys, key_length,
(size_t)max_keys, callbacks, &counter, 1);
char **list;
char **ptr;
memcached_stat_st memc_stat;
- memcached_return rc;
+ memcached_return_t rc;
list= memcached_stat_get_keys(memc, &memc_stat, &rc);
test_truth(rc == MEMCACHED_SUCCESS);
unsigned int x;
char **list;
char **ptr;
- memcached_return rc;
+ memcached_return_t rc;
memcached_stat_st *memc_stat;
memc_stat= memcached_stat(memc, NULL, &rc);
{
unsigned int x;
memcached_server_st *servers;
- memcached_return rc;
+ memcached_return_t rc;
char servername[]= "0.example.com";
servers= memcached_server_list_append_with_weight(NULL, servername, 400, 0, &rc);
return TEST_SUCCESS;
}
-static memcached_return clone_test_callback(memcached_st *parent __attribute__((unused)), memcached_st *memc_clone __attribute__((unused)))
+static memcached_return_t clone_test_callback(memcached_st *parent __attribute__((unused)), memcached_st *memc_clone __attribute__((unused)))
{
return MEMCACHED_SUCCESS;
}
-static memcached_return cleanup_test_callback(memcached_st *ptr __attribute__((unused)))
+static memcached_return_t cleanup_test_callback(memcached_st *ptr __attribute__((unused)))
{
return MEMCACHED_SUCCESS;
}
{
int x= 5;
int *test_ptr;
- memcached_return rc;
+ memcached_return_t rc;
rc= memcached_callback_set(memc, MEMCACHED_CALLBACK_USER_DATA, &x);
test_truth(rc == MEMCACHED_SUCCESS);
/* Test Clone Callback */
{
- memcached_clone_func clone_cb= (memcached_clone_func)clone_test_callback;
+ memcached_clone_fn clone_cb= (memcached_clone_fn)clone_test_callback;
void *clone_cb_ptr= *(void **)&clone_cb;
void *temp_function= NULL;
- memcached_return rc;
+ memcached_return_t rc;
rc= memcached_callback_set(memc, MEMCACHED_CALLBACK_CLONE_FUNCTION,
clone_cb_ptr);
/* Test Cleanup Callback */
{
- memcached_cleanup_func cleanup_cb=
- (memcached_cleanup_func)cleanup_test_callback;
+ memcached_cleanup_fn cleanup_cb=
+ (memcached_cleanup_fn)cleanup_test_callback;
void *cleanup_cb_ptr= *(void **)&cleanup_cb;
void *temp_function= NULL;
- memcached_return rc;
+ memcached_return_t rc;
rc= memcached_callback_set(memc, MEMCACHED_CALLBACK_CLONE_FUNCTION,
cleanup_cb_ptr);
static test_return_t fetch_all_results(memcached_st *memc)
{
- memcached_return rc= MEMCACHED_SUCCESS;
+ memcached_return_t rc= MEMCACHED_SUCCESS;
char return_key[MEMCACHED_MAX_KEY];
size_t return_key_length;
char *return_value;
uint32_t size= 0;
char key[10];
char randomstuff[6 * 1024];
- memcached_return rc;
+ memcached_return_t rc;
memset(randomstuff, 0, 6 * 1024);
for (x= 0, errors= 0, total= 0 ; total < 24576 ; x++)
{
- memcached_return rc= MEMCACHED_SUCCESS;
+ memcached_return_t rc= MEMCACHED_SUCCESS;
char buffer[SMALL_STRING_LEN];
uint32_t flags= 0;
size_t val_len= 0;
#define KEY_COUNT 3000 // * 1024576
static test_return_t user_supplied_bug3(memcached_st *memc)
{
- memcached_return rc;
+ memcached_return_t rc;
unsigned int setter;
unsigned int x;
char **keys;
/* Make sure we behave properly if server list has no values */
static test_return_t user_supplied_bug4(memcached_st *memc)
{
- memcached_return rc;
+ memcached_return_t rc;
const char *keys[]= {"fudge", "son", "food"};
size_t key_length[]= {5, 3, 4};
unsigned int x;
#define VALUE_SIZE_BUG5 1048064
static test_return_t user_supplied_bug5(memcached_st *memc)
{
- memcached_return rc;
+ memcached_return_t rc;
const char *keys[]= {"036790384900", "036790384902", "036790384904", "036790384906"};
size_t key_length[]= {strlen("036790384900"), strlen("036790384902"), strlen("036790384904"), strlen("036790384906")};
char return_key[MEMCACHED_MAX_KEY];
static test_return_t user_supplied_bug6(memcached_st *memc)
{
- memcached_return rc;
+ memcached_return_t rc;
const char *keys[]= {"036790384900", "036790384902", "036790384904", "036790384906"};
size_t key_length[]= {strlen("036790384900"), strlen("036790384902"), strlen("036790384904"), strlen("036790384906")};
char return_key[MEMCACHED_MAX_KEY];
static test_return_t user_supplied_bug8(memcached_st *memc __attribute__((unused)))
{
- memcached_return rc;
+ memcached_return_t rc;
memcached_st *mine;
memcached_st *memc_clone;
/* Test flag store/retrieve */
static test_return_t user_supplied_bug7(memcached_st *memc)
{
- memcached_return rc;
+ memcached_return_t rc;
const char *keys= "036790384900";
size_t key_length= strlen(keys);
char return_key[MEMCACHED_MAX_KEY];
static test_return_t user_supplied_bug9(memcached_st *memc)
{
- memcached_return rc;
+ memcached_return_t rc;
const char *keys[]= {"UDATA:edevil@sapo.pt", "fudge&*@#", "for^#@&$not"};
size_t key_length[3];
unsigned int x;
size_t value_length= 512;
unsigned int x;
size_t key_len= 3;
- memcached_return rc;
+ memcached_return_t rc;
unsigned int set= 1;
memcached_st *mclone= memcached_clone(NULL, memc);
int32_t timeout;
size_t value_length= 512;
unsigned int x;
size_t key_len= 3;
- memcached_return rc;
+ memcached_return_t rc;
unsigned int set= 1;
int32_t timeout;
memcached_st *mclone= memcached_clone(NULL, memc);
*/
static test_return_t user_supplied_bug12(memcached_st *memc)
{
- memcached_return rc;
+ memcached_return_t rc;
uint32_t flags;
size_t value_length;
char *value;
{
char key[] = "key34567890";
char *overflow;
- memcached_return rc;
+ memcached_return_t rc;
size_t overflowSize;
char commandFirst[]= "set key34567890 0 0 ";
{
size_t setter= 1;
memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_TCP_NODELAY, setter);
- memcached_return rc;
+ memcached_return_t rc;
const char *key= "foo";
char *value;
size_t value_length= 18000;
static test_return_t user_supplied_bug15(memcached_st *memc)
{
uint32_t x;
- memcached_return rc;
+ memcached_return_t rc;
const char *key= "mykey";
char *value;
size_t length;
/* Check the return sizes on FLAGS to make sure it stores 32bit unsigned values correctly */
static test_return_t user_supplied_bug16(memcached_st *memc)
{
- memcached_return rc;
+ memcached_return_t rc;
const char *key= "mykey";
char *value;
size_t length;
/* Check the validity of chinese key*/
static test_return_t user_supplied_bug17(memcached_st *memc)
{
- memcached_return rc;
+ memcached_return_t rc;
const char *key= "豆瓣";
const char *value="我们在炎热抑郁的夏天无法停止豆瓣";
char *value2;
{
memcached_st *m;
memcached_server_st *s;
- memcached_return res;
+ memcached_return_t res;
(void)memc;
/* CAS test from Andei */
static test_return_t user_supplied_bug20(memcached_st *memc)
{
- memcached_return status;
+ memcached_return_t status;
memcached_result_st *result, result_obj;
const char *key = "abc";
size_t key_len = strlen("abc");
#include "ketama_test_cases.h"
static test_return_t user_supplied_bug18(memcached_st *trash)
{
- memcached_return rc;
+ memcached_return_t rc;
uint64_t value;
int x;
memcached_server_st *server_pool;
static test_return_t _user_supplied_bug21(memcached_st* memc, size_t key_count)
{
- memcached_return rc;
+ memcached_return_t rc;
unsigned int x;
char **keys;
size_t* key_lengths;
return TEST_SUCCESS;
}
-static memcached_return pre_binary(memcached_st *memc);
+static memcached_return_t pre_binary(memcached_st *memc);
static test_return_t user_supplied_bug21(memcached_st *memc)
{
{
(void) trash;
- memcached_return rc;
+ memcached_return_t rc;
memcached_st *memc= memcached_create(NULL);
test_truth(memc);
{
(void) trash;
- memcached_return rc;
+ memcached_return_t rc;
memcached_st *memc= memcached_create(NULL);
test_truth(memc);
for (x= 0; x < 1024; x++)
{
- memcached_return rc;
+ memcached_return_t rc;
rc= memcached_string_append(string, buffer, SMALL_STRING_LEN);
test_truth(rc == MEMCACHED_SUCCESS);
}
static test_return_t string_alloc_append_toobig(memcached_st *memc)
{
- memcached_return rc;
+ memcached_return_t rc;
unsigned int x;
char buffer[SMALL_STRING_LEN];
memcached_string_st *string;
static test_return_t generate_data_with_stats(memcached_st *memc)
{
memcached_stat_st *stat_p;
- memcached_return rc;
+ memcached_return_t rc;
uint32_t host_index= 0;
execute_set(memc, global_pairs, global_count);
static test_return_t get_read_count(memcached_st *memc)
{
unsigned int x;
- memcached_return rc;
+ memcached_return_t rc;
memcached_st *memc_clone;
memc_clone= memcached_clone(NULL, memc);
static test_return_t get_read(memcached_st *memc)
{
unsigned int x;
- memcached_return rc;
+ memcached_return_t rc;
{
char *return_value;
static test_return_t mget_read(memcached_st *memc)
{
- memcached_return rc;
+ memcached_return_t rc;
rc= memcached_mget(memc, global_keys, global_keys_length, global_count);
test_truth(rc == MEMCACHED_SUCCESS);
static test_return_t mget_read_result(memcached_st *memc)
{
- memcached_return rc;
+ memcached_return_t rc;
rc= memcached_mget(memc, global_keys, global_keys_length, global_count);
test_truth(rc == MEMCACHED_SUCCESS);
static test_return_t mget_read_function(memcached_st *memc)
{
- memcached_return rc;
+ memcached_return_t rc;
unsigned int counter;
- memcached_execute_function callbacks[1];
+ memcached_execute_fn callbacks[1];
rc= memcached_mget(memc, global_keys, global_keys_length, global_count);
test_truth(rc == MEMCACHED_SUCCESS);
static test_return_t add_host_test1(memcached_st *memc)
{
unsigned int x;
- memcached_return rc;
+ memcached_return_t rc;
char servername[]= "0.example.com";
memcached_server_st *servers;
return TEST_SUCCESS;
}
-static memcached_return pre_nonblock(memcached_st *memc)
+static memcached_return_t pre_nonblock(memcached_st *memc)
{
memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_NO_BLOCK, 0);
return MEMCACHED_SUCCESS;
}
-static memcached_return pre_nonblock_binary(memcached_st *memc)
+static memcached_return_t pre_nonblock_binary(memcached_st *memc)
{
- memcached_return rc= MEMCACHED_FAILURE;
+ memcached_return_t rc= MEMCACHED_FAILURE;
memcached_st *memc_clone;
memc_clone= memcached_clone(NULL, memc);
return rc;
}
-static memcached_return pre_murmur(memcached_st *memc)
+static memcached_return_t pre_murmur(memcached_st *memc)
{
memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_HASH, (uint64_t)MEMCACHED_HASH_MURMUR);
return MEMCACHED_SUCCESS;
}
-static memcached_return pre_jenkins(memcached_st *memc)
+static memcached_return_t pre_jenkins(memcached_st *memc)
{
memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_HASH, (uint64_t)MEMCACHED_HASH_JENKINS);
}
-static memcached_return pre_md5(memcached_st *memc)
+static memcached_return_t pre_md5(memcached_st *memc)
{
memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_HASH, (uint64_t)MEMCACHED_HASH_MD5);
return MEMCACHED_SUCCESS;
}
-static memcached_return pre_crc(memcached_st *memc)
+static memcached_return_t pre_crc(memcached_st *memc)
{
memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_HASH, (uint64_t)MEMCACHED_HASH_CRC);
return MEMCACHED_SUCCESS;
}
-static memcached_return pre_hsieh(memcached_st *memc)
+static memcached_return_t pre_hsieh(memcached_st *memc)
{
#ifdef HAVE_HSIEH_HASH
memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_HASH, (uint64_t)MEMCACHED_HASH_HSIEH);
#endif
}
-static memcached_return pre_hash_fnv1_64(memcached_st *memc)
+static memcached_return_t pre_hash_fnv1_64(memcached_st *memc)
{
memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_HASH, (uint64_t)MEMCACHED_HASH_FNV1_64);
return MEMCACHED_SUCCESS;
}
-static memcached_return pre_hash_fnv1a_64(memcached_st *memc)
+static memcached_return_t pre_hash_fnv1a_64(memcached_st *memc)
{
memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_HASH, (uint64_t)MEMCACHED_HASH_FNV1A_64);
return MEMCACHED_SUCCESS;
}
-static memcached_return pre_hash_fnv1_32(memcached_st *memc)
+static memcached_return_t pre_hash_fnv1_32(memcached_st *memc)
{
memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_HASH, (uint64_t)MEMCACHED_HASH_FNV1_32);
return MEMCACHED_SUCCESS;
}
-static memcached_return pre_hash_fnv1a_32(memcached_st *memc)
+static memcached_return_t pre_hash_fnv1a_32(memcached_st *memc)
{
memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_HASH, (uint64_t)MEMCACHED_HASH_FNV1A_32);
return MEMCACHED_SUCCESS;
}
-static memcached_return pre_behavior_ketama(memcached_st *memc)
+static memcached_return_t pre_behavior_ketama(memcached_st *memc)
{
- memcached_return rc;
+ memcached_return_t rc;
uint64_t value;
rc= memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_KETAMA, 1);
return MEMCACHED_SUCCESS;
}
-static memcached_return pre_behavior_ketama_weighted(memcached_st *memc)
+static memcached_return_t pre_behavior_ketama_weighted(memcached_st *memc)
{
- memcached_return rc;
+ memcached_return_t rc;
uint64_t value;
rc= memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_KETAMA_WEIGHTED, 1);
return MEMCACHED_SUCCESS;
}
-static memcached_return pre_binary(memcached_st *memc)
+static memcached_return_t pre_binary(memcached_st *memc)
{
- memcached_return rc= MEMCACHED_FAILURE;
+ memcached_return_t rc= MEMCACHED_FAILURE;
memcached_st *memc_clone;
memc_clone= memcached_clone(NULL, memc);
return rc;
}
-static memcached_return pre_replication(memcached_st *memc)
+static memcached_return_t pre_replication(memcached_st *memc)
{
if (pre_binary(memc) != MEMCACHED_SUCCESS)
return MEMCACHED_FAILURE;
* Make sure that we store the item on all servers
* (master + replicas == number of servers)
*/
- memcached_return rc;
+ memcached_return_t rc;
rc= memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_NUMBER_OF_REPLICAS,
memc->number_of_hosts - 1);
assert(rc == MEMCACHED_SUCCESS);
return rc;
}
-static memcached_return pre_replication_noblock(memcached_st *memc)
+static memcached_return_t pre_replication_noblock(memcached_st *memc)
{
- memcached_return rc= MEMCACHED_FAILURE;
+ memcached_return_t rc= MEMCACHED_FAILURE;
if (pre_replication(memc) == MEMCACHED_SUCCESS &&
pre_nonblock(memc) == MEMCACHED_SUCCESS)
rc= MEMCACHED_SUCCESS;
return calloc(nelem, size);
}
-static memcached_return set_prefix(memcached_st *memc)
+static memcached_return_t set_prefix(memcached_st *memc)
{
- memcached_return rc;
+ memcached_return_t rc;
const char *key= "mine";
char *value;
}
#ifdef MEMCACHED_ENABLE_DEPRECATED
-static memcached_return deprecated_set_memory_alloc(memcached_st *memc)
+static memcached_return_t deprecated_set_memory_alloc(memcached_st *memc)
{
void *test_ptr= NULL;
void *cb_ptr= NULL;
{
- memcached_malloc_function malloc_cb=
- (memcached_malloc_function)my_malloc;
+ memcached_malloc_fn malloc_cb=
+ (memcached_malloc_fn)my_malloc;
cb_ptr= *(void **)&malloc_cb;
- memcached_return rc;
+ memcached_return_t rc;
rc= memcached_callback_set(memc, MEMCACHED_CALLBACK_MALLOC_FUNCTION, cb_ptr);
assert(rc == MEMCACHED_SUCCESS);
}
{
- memcached_realloc_function realloc_cb=
- (memcached_realloc_function)my_realloc;
+ memcached_realloc_fn realloc_cb=
+ (memcached_realloc_fn)my_realloc;
cb_ptr= *(void **)&realloc_cb;
- memcached_return rc;
+ memcached_return_t rc;
rc= memcached_callback_set(memc, MEMCACHED_CALLBACK_REALLOC_FUNCTION, cb_ptr);
assert(rc == MEMCACHED_SUCCESS);
}
{
- memcached_free_function free_cb=
- (memcached_free_function)my_free;
+ memcached_free_fn free_cb=
+ (memcached_free_fn)my_free;
cb_ptr= *(void **)&free_cb;
- memcached_return rc;
+ memcached_return_t rc;
rc= memcached_callback_set(memc, MEMCACHED_CALLBACK_FREE_FUNCTION, cb_ptr);
assert(rc == MEMCACHED_SUCCESS);
}
#endif
-static memcached_return set_memory_alloc(memcached_st *memc)
+static memcached_return_t set_memory_alloc(memcached_st *memc)
{
- memcached_return rc;
+ memcached_return_t rc;
rc= memcached_set_memory_allocators(memc, NULL, my_free,
my_realloc, my_calloc);
assert(rc == MEMCACHED_FAILURE);
rc= memcached_set_memory_allocators(memc, my_malloc, my_free,
my_realloc, my_calloc);
- memcached_malloc_function mem_malloc;
- memcached_free_function mem_free;
- memcached_realloc_function mem_realloc;
- memcached_calloc_function mem_calloc;
+ memcached_malloc_fn mem_malloc;
+ memcached_free_fn mem_free;
+ memcached_realloc_fn mem_realloc;
+ memcached_calloc_fn mem_calloc;
memcached_get_memory_allocators(memc, &mem_malloc, &mem_free,
&mem_realloc, &mem_calloc);
return MEMCACHED_SUCCESS;
}
-static memcached_return enable_consistent(memcached_st *memc)
+static memcached_return_t enable_consistent(memcached_st *memc)
{
- memcached_server_distribution value= MEMCACHED_DISTRIBUTION_CONSISTENT;
- memcached_hash hash;
+ memcached_server_distribution_t value= MEMCACHED_DISTRIBUTION_CONSISTENT;
+ memcached_hash_t hash;
memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_DISTRIBUTION, value);
if (pre_hsieh(memc) != MEMCACHED_SUCCESS)
return MEMCACHED_FAILURE;
- value= (memcached_server_distribution)memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_DISTRIBUTION);
+ value= (memcached_server_distribution_t)memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_DISTRIBUTION);
assert(value == MEMCACHED_DISTRIBUTION_CONSISTENT);
- hash= (memcached_hash)memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_HASH);
+ hash= (memcached_hash_t)memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_HASH);
assert(hash == MEMCACHED_HASH_HSIEH);
return MEMCACHED_SUCCESS;
}
-static memcached_return enable_cas(memcached_st *memc)
+static memcached_return_t enable_cas(memcached_st *memc)
{
unsigned int set= 1;
return MEMCACHED_FAILURE;
}
-static memcached_return check_for_1_2_3(memcached_st *memc)
+static memcached_return_t check_for_1_2_3(memcached_st *memc)
{
memcached_version(memc);
return MEMCACHED_FAILURE;
}
-static memcached_return pre_unix_socket(memcached_st *memc)
+static memcached_return_t pre_unix_socket(memcached_st *memc)
{
- memcached_return rc;
+ memcached_return_t rc;
struct stat buf;
memcached_server_list_free(memc->hosts);
return rc;
}
-static memcached_return pre_nodelay(memcached_st *memc)
+static memcached_return_t pre_nodelay(memcached_st *memc)
{
memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_NO_BLOCK, 0);
memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_TCP_NODELAY, 0);
return MEMCACHED_SUCCESS;
}
-static memcached_return pre_settimer(memcached_st *memc)
+static memcached_return_t pre_settimer(memcached_st *memc)
{
memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_SND_TIMEOUT, 1000);
memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_RCV_TIMEOUT, 1000);
return MEMCACHED_SUCCESS;
}
-static memcached_return poll_timeout(memcached_st *memc)
+static memcached_return_t poll_timeout(memcached_st *memc)
{
size_t timeout;
static test_return_t noreply_test(memcached_st *memc)
{
- memcached_return ret;
+ memcached_return_t ret;
ret= memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_NOREPLY, 1);
test_truth(ret == MEMCACHED_SUCCESS);
ret= memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_BUFFER_REQUESTS, 1);
static test_return_t analyzer_test(memcached_st *memc)
{
- memcached_return rc;
+ memcached_return_t rc;
memcached_stat_st *memc_stat;
memcached_analysis_st *report;
}
/* Count the objects */
-static memcached_return callback_dump_counter(memcached_st *ptr __attribute__((unused)),
+static memcached_return_t callback_dump_counter(memcached_st *ptr __attribute__((unused)),
const char *key __attribute__((unused)),
size_t key_length __attribute__((unused)),
void *context)
static test_return_t dump_test(memcached_st *memc)
{
- memcached_return rc;
+ memcached_return_t rc;
uint32_t counter= 0;
- memcached_dump_func callbacks[1];
+ memcached_dump_fn callbacks[1];
test_return_t main_rc;
callbacks[0]= &callback_dump_counter;
memcached_pool_st* pool= memcached_pool_create(memc, 5, 10);
test_truth(pool != NULL);
memcached_st* mmc[10];
- memcached_return rc;
+ memcached_return_t rc;
for (int x= 0; x < 10; ++x) {
mmc[x]= memcached_pool_pop(pool, false, &rc);
static test_return_t replication_set_test(memcached_st *memc)
{
- memcached_return rc;
+ memcached_return_t rc;
memcached_st *memc_clone= memcached_clone(NULL, memc);
memcached_behavior_set(memc_clone, MEMCACHED_BEHAVIOR_NUMBER_OF_REPLICAS, 0);
static test_return_t replication_get_test(memcached_st *memc)
{
- memcached_return rc;
+ memcached_return_t rc;
/*
* Don't do the following in your code. I am abusing the internal details
static test_return_t replication_mget_test(memcached_st *memc)
{
- memcached_return rc;
+ memcached_return_t rc;
memcached_st *memc_clone= memcached_clone(NULL, memc);
memcached_behavior_set(memc_clone, MEMCACHED_BEHAVIOR_NUMBER_OF_REPLICAS, 0);
static test_return_t replication_randomize_mget_test(memcached_st *memc)
{
memcached_result_st result_obj;
- memcached_return rc;
+ memcached_return_t rc;
memcached_st *memc_clone= memcached_clone(NULL, memc);
memcached_behavior_set(memc_clone, MEMCACHED_BEHAVIOR_NUMBER_OF_REPLICAS, 3);
memcached_behavior_set(memc_clone, MEMCACHED_BEHAVIOR_RANDOMIZE_REPLICA_READ, 1);
static test_return_t replication_delete_test(memcached_st *memc)
{
- memcached_return rc;
+ memcached_return_t rc;
memcached_st *memc_clone= memcached_clone(NULL, memc);
/* Delete the items from all of the servers except 1 */
uint64_t repl= memcached_behavior_get(memc,
** There is a little bit of a hack here, instead of removing
** the servers, I just set num host to 0 and them add then new udp servers
**/
-static memcached_return init_udp(memcached_st *memc)
+static memcached_return_t init_udp(memcached_st *memc)
{
memcached_version(memc);
/* For the time being, only support udp test for >= 1.2.6 && < 1.3 */
return MEMCACHED_SUCCESS;
}
-static memcached_return binary_init_udp(memcached_st *memc)
+static memcached_return_t binary_init_udp(memcached_st *memc)
{
pre_binary(memc);
return init_udp(memc);
unsigned int num_iters= 1025; //request id rolls over at 1024
for (x= 0; x < num_iters;x++)
{
- memcached_return rc;
+ memcached_return_t rc;
const char *key= "foo";
const char *value= "when we sanitize";
uint16_t *expected_ids= get_udp_request_ids(memc);
static test_return_t udp_set_too_big_test(memcached_st *memc)
{
- memcached_return rc;
+ memcached_return_t rc;
const char *key= "bar";
char value[MAX_UDP_DATAGRAM_LENGTH];
uint16_t *expected_ids= get_udp_request_ids(memc);
unsigned int num_iters= 1025; //request id rolls over at 1024
for (x= 0; x < num_iters;x++)
{
- memcached_return rc;
+ memcached_return_t rc;
const char *key= "foo";
uint16_t *expected_ids=get_udp_request_ids(memc);
unsigned int server_key= memcached_generate_hash(memc, key, strlen(key));
static test_return_t udp_verbosity_test(memcached_st *memc)
{
- memcached_return rc;
+ memcached_return_t rc;
uint16_t *expected_ids= get_udp_request_ids(memc);
unsigned int x;
for (x= 0; x < memc->number_of_hosts;x++)
static test_return_t udp_flush_test(memcached_st *memc)
{
- memcached_return rc;
+ memcached_return_t rc;
uint16_t *expected_ids= get_udp_request_ids(memc);
unsigned int x;
for (x= 0; x < memc->number_of_hosts;x++)
static test_return_t udp_incr_test(memcached_st *memc)
{
- memcached_return rc;
+ memcached_return_t rc;
const char *key= "incr";
const char *value= "1";
rc= memcached_set(memc, key, strlen(key),
static test_return_t udp_decr_test(memcached_st *memc)
{
- memcached_return rc;
+ memcached_return_t rc;
const char *key= "decr";
const char *value= "1";
rc= memcached_set(memc, key, strlen(key),
static test_return_t udp_stat_test(memcached_st *memc)
{
memcached_stat_st * rv= NULL;
- memcached_return rc;
+ memcached_return_t rc;
char args[]= "";
uint16_t *expected_ids = get_udp_request_ids(memc);
rv = memcached_stat(memc, args, &rc);
static test_return_t udp_version_test(memcached_st *memc)
{
- memcached_return rc;
+ memcached_return_t rc;
uint16_t *expected_ids = get_udp_request_ids(memc);
rc = memcached_version(memc);
test_truth(rc == MEMCACHED_NOT_SUPPORTED);
static test_return_t udp_get_test(memcached_st *memc)
{
- memcached_return rc;
+ memcached_return_t rc;
const char *key= "foo";
size_t vlen;
uint16_t *expected_ids = get_udp_request_ids(memc);
static test_return_t hsieh_avaibility_test (memcached_st *memc)
{
- memcached_return expected_rc= MEMCACHED_FAILURE;
+ memcached_return_t expected_rc= MEMCACHED_FAILURE;
#ifdef HAVE_HSIEH_HASH
expected_rc= MEMCACHED_SUCCESS;
#endif
- memcached_return rc= memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_HASH,
+ memcached_return_t rc= memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_HASH,
(uint64_t)MEMCACHED_HASH_HSIEH);
test_truth(rc == expected_rc);
return TEST_SUCCESS;
static test_return_t ketama_compatibility_libmemcached(memcached_st *trash)
{
- memcached_return rc;
+ memcached_return_t rc;
uint64_t value;
int x;
memcached_server_st *server_pool;
static test_return_t ketama_compatibility_spymemcached(memcached_st *trash)
{
- memcached_return rc;
+ memcached_return_t rc;
uint64_t value;
int x;
memcached_server_st *server_pool;
if (pre_binary(memc) != MEMCACHED_SUCCESS)
return TEST_SKIPPED;
- memcached_return ret;
+ memcached_return_t ret;
const char *key= "regression_bug_434484";
size_t keylen= strlen(key);
if (pre_binary(memc) != MEMCACHED_SUCCESS)
return TEST_SKIPPED;
- memcached_return rc;
+ memcached_return_t rc;
unsigned int counter= 0;
- memcached_execute_function callbacks[1]= { [0]= &callback_counter };
+ memcached_execute_fn callbacks[1]= { [0]= &callback_counter };
/*
* I only want to hit only _one_ server so I know the number of requests I'm
static test_return_t regression_bug_434843_buffered(memcached_st *memc)
{
- memcached_return rc;
+ memcached_return_t rc;
rc= memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_BUFFER_REQUESTS, 1);
assert(rc == MEMCACHED_SUCCESS);
static test_return_t regression_bug_421108(memcached_st *memc)
{
- memcached_return rc;
+ memcached_return_t rc;
memcached_stat_st *memc_stat= memcached_stat(memc, NULL, &rc);
assert(rc == MEMCACHED_SUCCESS);
*/
static test_return_t regression_bug_442914(memcached_st *memc)
{
- memcached_return rc;
+ memcached_return_t rc;
rc= memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_NOREPLY, 1);
assert(rc == MEMCACHED_SUCCESS);
memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_TCP_NODELAY, 1);
if (memc->number_of_hosts < 3 || pre_replication(memc) != MEMCACHED_SUCCESS)
return TEST_SKIPPED;
- memcached_return rc;
+ memcached_return_t rc;
rc= memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_NUMBER_OF_REPLICAS, 2);
assert(rc == MEMCACHED_SUCCESS);
assert(rc == MEMCACHED_SUCCESS);
unsigned int counter= 0;
- memcached_execute_function callbacks[1]= { [0]= &callback_counter };
+ memcached_execute_fn callbacks[1]= { [0]= &callback_counter };
rc= memcached_fetch_execute(memc, callbacks, (void *)&counter, 1);
/* Verify that we received all of the key/value pairs */
assert(counter == (unsigned int)max_keys);
assert(memcached_delete(memc_clone, "foo", 3, 1) == MEMCACHED_INVALID_ARGUMENTS);
/* If we don't know the server version, we should get a protocol error */
- memcached_return rc= memcached_delete(memc, "foo", 3, 1);
+ memcached_return_t rc= memcached_delete(memc, "foo", 3, 1);
/* but there is a bug in some of the memcached servers (1.4) that treats
* the counter as noreply so it doesn't send the proper error message
*/
*/
static test_return_t test_get_last_disconnect(memcached_st *memc)
{
- memcached_return rc;
+ memcached_return_t rc;
memcached_server_st *disconnected_server;
/* With the working set of server */
*/
static test_return_t wrong_failure_counter_test(memcached_st *memc)
{
- memcached_return rc;
+ memcached_return_t rc;
/* Set value to force connection to the server */
const char *key= "marmotte";
test_return_t mget_result_function(memcached_st *memc);
test_return_t basic_behavior(memcached_st *memc);
test_return_t mget_test(memcached_st *memc);
- memcached_return callback_counter(memcached_st *,
+ memcached_return_t callback_counter(memcached_st *,
memcached_result_st *,
void *context);
void *world_create(void);
}
/* Count the results */
-memcached_return callback_counter(memcached_st *,
- memcached_result_st *,
- void *context)
+memcached_return_t callback_counter(memcached_st *,
+ memcached_result_st *,
+ void *context)
{
unsigned int *counter= static_cast<unsigned int *>(context);
values.push_back(&val2);
values.push_back(&val3);
unsigned int counter;
- memcached_execute_function callbacks[1];
+ memcached_execute_fn callbacks[1];
/* We need to empty the server before we continue the test */
rc= mc.flush(0);
{
Memcache mc(memc);
bool rc;
- memcached_return mc_rc;
+ memcached_return_t mc_rc;
vector<string> keys;
vector< vector<char> *> values;
keys.reserve(3);
{
unsigned int loop;
memcached_st *memc;
- memcached_return rc;
+ memcached_return_t rc;
struct timeval start_time, end_time;
long int load_time;
struct collection_st {
const char *name;
- memcached_return (*pre)(memcached_st *memc);
- memcached_return (*post)(memcached_st *memc);
+ memcached_return_t (*pre)(memcached_st *memc);
+ memcached_return_t (*post)(memcached_st *memc);
test_st *tests;
};
test_return_t set_test(memcached_st *memc)
{
- memcached_return rc;
+ memcached_return_t rc;
const char *key= "foo";
const char *value= "when we sanitize";