callback.h   callback.h 
/* /* LibMemcached
* Summary: Definition of the callback interface * 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.
* *
* Author: Trond Norbye * Summary: Change any of the possible callbacks.
*/
#ifndef LIBMEMCACHEDPROTOCOL_CALLBACK_H
#define LIBMEMCACHEDPROTOCOL_CALLBACK_H
/**
* Callback to send data back from a successful GET/GETQ/GETK/GETKQ command
*
* @param cookie Just pass along the cookie supplied in the callback
* @param key What to insert as key in the reply
* @param keylen The length of the key
* @param body What to store in the body of the package
* @param bodylen The number of bytes of the body
* @param flags The flags stored with the item
* @param cas The CAS value to insert into the response (should be 0
* if you don't care)
*/
typedef protocol_binary_response_status
(*memcached_binary_protocol_get_response_handler)(const void *cookie,
const void *key,
uint16_t keylen,
const void *body,
uint32_t bodylen,
uint32_t flags,
uint64_t cas);
/**
* Callback to send data back from a STAT command
*
* @param cookie Just pass along the cookie supplied in the callback
* @param key What to insert as key in the reply
* @param keylen The length of the key
* @param body What to store in the body of the package
* @param bodylen The number of bytes of the body
*/
typedef protocol_binary_response_status
(*memcached_binary_protocol_stat_response_handler)(const void *cookie,
const void *key,
uint16_t keylen,
const void *body,
uint32_t bodylen);
/**
* Callback to send data back from a VERSION command
*
* @param cookie Just pass along the cookie supplied in the callback
* @param text The version string
* @param length The number of bytes in the version string
*/
typedef protocol_binary_response_status
(*memcached_binary_protocol_version_response_handler)(const void *cookie,
const void *text,
uint32_t length);
/**
* In the low level interface you need to format the response
* packet yourself (giving you complete freedom :-)
*
* @param cookie Just pass along the cookie supplied in the callback
* @param request Pointer to the request packet you are sending a reply to
* @param response Pointer to the response packet to send
* *
*/ */
typedef protocol_binary_response_status (*memcached_binary_protocol_raw_res
ponse_handler)(const void *cookie,
protocol_bin
ary_request_header *request,
protocol_bin
ary_response_header *response);
/**
* In the low lever interface you have to do most of the work by
* yourself, but it also gives you a lot of freedom :-)
* @param cookie identification for this connection, just pass it along to
* the response handler
* @param header the command received over the wire. Never try to access
* <u>anything</u> outside the command.
* @param resonse_handler call this function to send data back to the clien
t
*/
typedef protocol_binary_response_status (*memcached_binary_protocol_command
_handler)(const void *cookie,
protocol_binary_request_
header *header,
memcached_binary_protoco
l_raw_response_handler response_handler);
/**
* The raw interface to the packets is implemented in version 0. It contain
s
* just an array with command handlers. The inxed in the array is the
* com code.
*/
typedef struct {
memcached_binary_protocol_command_handler comcode[256];
} memcached_binary_protocol_callback_v0_st;
/**
* The first version of the callback struct containing all of the
* documented commands in the initial release of the binary protocol
* (aka. memcached 1.4.0).
*
* You might miss the Q commands (addq etc) but the response function
* knows how to deal with them so you don't need to worry about that :-)
*/
typedef struct {
/**
* Add an item to the cache
* @param cookie id of the client receiving the command
* @param key the key to add
* @param len the length of the key
* @param val the value to store for the key (may be NIL)
* @param vallen the length of the data
* @param flags the flags to store with the key
* @param exptime the expiry time for the key-value pair
* @param cas the resulting cas for the add operation (if success)
*/
protocol_binary_response_status (*add)(const void *cookie,
const void *key,
uint16_t keylen,
const void* val,
uint32_t vallen,
uint32_t flags,
uint32_t exptime,
uint64_t *cas);
/**
* Append data to an <b>existing</b> key-value pair.
*
* @param cookie id of the client receiving the command
* @param key the key to add data to
* @param len the length of the key
* @param val the value to append to the value
* @param vallen the length of the data
* @param cas the CAS in the request
* @param result_cas the resulting cas for the append operation
*
*/
protocol_binary_response_status (*append)(const void *cookie,
const void *key,
uint16_t keylen,
const void* val,
uint32_t vallen,
uint64_t cas,
uint64_t *result_cas);
/**
* Decrement the value for a key
*
* @param cookie id of the client receiving the command
* @param key the key to decrement the value for
* @param len the length of the key
* @param delta the amount to decrement
* @param initial initial value to store (if the key doesn't exist)
* @param expiration expiration time for the object (if the key doesn't
exist)
* @param cas the CAS in the request
* @param result the result from the decrement
* @param result_cas the cas of the item
*
*/
protocol_binary_response_status (*decrement)(const void *cookie,
const void *key,
uint16_t keylen,
uint64_t delta,
uint64_t initial,
uint32_t expiration,
uint64_t *result,
uint64_t *result_cas);
/** #ifndef __MEMCACHED_CALLBACK_H__
* Delete an existing key #define __MEMCACHED_CALLBACK_H__
*
* @param cookie id of the client receiving the command
* @param key the key to delete
* @param len the length of the key
* @param cas the CAS in the request
*/
protocol_binary_response_status (*delete)(const void *cookie,
const void *key,
uint16_t keylen,
uint64_t cas);
/** #ifdef __cplusplus
* Flush the cache extern "C" {
* #endif
* @param cookie id of the client receiving the command
* @param when when the cache should be flushed (0 == immediately)
*/
protocol_binary_response_status (*flush)(const void *cookie,
uint32_t when);
/**
* Get a key-value pair
*
* @param cookie id of the client receiving the command
* @param key the key to get
* @param len the length of the key
* @param response_handler to send the result back to the client
*/
protocol_binary_response_status (*get)(const void *cookie,
const void *key,
uint16_t keylen,
memcached_binary_protocol_get_res
ponse_handler response_handler);
/**
* Increment the value for a key
*
* @param cookie id of the client receiving the command
* @param key the key to increment the value on
* @param len the length of the key
* @param delta the amount to increment
* @param initial initial value to store (if the key doesn't exist)
* @param expiration expiration time for the object (if the key doesn't
exist)
* @param cas the CAS in the request
* @param result the result from the decrement
* @param result_cas the cas of the item
*
*/
protocol_binary_response_status (*increment)(const void *cookie,
const void *key,
uint16_t keylen,
uint64_t delta,
uint64_t initial,
uint32_t expiration,
uint64_t *result,
uint64_t *result_cas);
/**
* The noop command was received. This is just a notification callback (
the
* response is automatically created).
*
* @param cookie id of the client receiving the command
*/
protocol_binary_response_status (*noop)(const void *cookie);
/**
* Prepend data to an <b>existing</b> key-value pair.
*
* @param cookie id of the client receiving the command
* @param key the key to prepend data to
* @param len the length of the key
* @param val the value to prepend to the value
* @param vallen the length of the data
* @param cas the CAS in the request
* @param result-cas the cas id of the item
*
*/
protocol_binary_response_status (*prepend)(const void *cookie,
const void *key,
uint16_t keylen,
const void* val,
uint32_t vallen,
uint64_t cas,
uint64_t *result_cas);
/**
* The quit command was received. This is just a notification callback (
the
* response is automatically created).
*
* @param cookie id of the client receiving the command
*/
protocol_binary_response_status (*quit)(const void *cookie);
/**
* Replace an <b>existing</b> item to the cache
*
* @param cookie id of the client receiving the command
* @param key the key to replace the content for
* @param len the length of the key
* @param val the value to store for the key (may be NIL)
* @param vallen the length of the data
* @param flags the flags to store with the key
* @param exptime the expiry time for the key-value pair
* @param cas the cas id in the request
* @param result_cas the cas id of the item
*/
protocol_binary_response_status (*replace)(const void *cookie,
const void *key,
uint16_t keylen,
const void* val,
uint32_t vallen,
uint32_t flags,
uint32_t exptime,
uint64_t cas,
uint64_t *result_cas);
/**
* Set a key-value pair in the cache
*
* @param cookie id of the client receiving the command
* @param key the key to insert
* @param len the length of the key
* @param val the value to store for the key (may be NIL)
* @param vallen the length of the data
* @param flags the flags to store with the key
* @param exptime the expiry time for the key-value pair
* @param cas the cas id in the request
* @param result_cas the cas id of the new item
*/
protocol_binary_response_status (*set)(const void *cookie,
const void *key,
uint16_t keylen,
const void* val,
uint32_t vallen,
uint32_t flags,
uint32_t exptime,
uint64_t cas,
uint64_t *result_cas);
/**
* Get status information
*
* @param cookie id of the client receiving the command
* @param key the key to get status for (or NIL to request all status).
* Remember to insert the terminating packet if multiple
* packets should be returned.
* @param keylen the length of the key
* @param response_handler to send the result back to the client, but
* don't send reply on success!
*
*/
protocol_binary_response_status (*stat)(const void *cookie,
const void *key,
uint16_t keylen,
memcached_binary_protocol_stat_r
esponse_handler response_handler);
/**
* Get the version information
*
* @param cookie id of the client receiving the command
* @param response_handler to send the result back to the client, but
* don't send reply on success!
*
*/
protocol_binary_response_status (*version)(const void *cookie,
memcached_binary_protocol_ver
sion_response_handler response_handler);
} memcached_binary_protocol_callback_v1_st;
/**
* The version numbers for the different callback structures.
*/
typedef enum {
/** Version 0 is a lowlevel interface that tries to maximize your freedo
m */
MEMCACHED_PROTOCOL_HANDLER_V0= 0,
/**
* Version 1 abstracts more of the protocol details, and let you work at
* a logical level
*/
MEMCACHED_PROTOCOL_HANDLER_V1= 1,
} memcached_protocol_interface_version_t;
/**
* Definition of the protocol callback structure.
*/
typedef struct {
/**
* The interface version you provide callbacks for.
*/
memcached_protocol_interface_version_t interface_version;
/**
* Callback fired just before the command will be executed.
*
* @param cookie id of the client receiving the command
* @param header the command header as received on the wire. If you look
* at the content you <b>must</b> ensure that you don't
* try to access beyond the end of the message.
*/
void (*pre_execute)(const void *cookie,
protocol_binary_request_header *header);
/**
* Callback fired just after the command was exected (please note
* that the data transfer back to the client is not finished at this
* time).
*
* @param cookie id of the client receiving the command
* @param header the command header as received on the wire. If you look
* at the content you <b>must</b> ensure that you don't
* try to access beyond the end of the message.
*/
void (*post_execute)(const void *cookie,
protocol_binary_request_header *header);
/**
* Callback fired if no specialized callback is registered for this
* specific command code.
*
* @param cookie id of the client receiving the command
* @param header the command header as received on the wire. You <b>must
</b>
* ensure that you don't try to access beyond the end of t
he
* message.
* @param response_handler The response handler to send data back.
*/
protocol_binary_response_status (*unknown)(const void *cookie,
protocol_binary_request_heade
r *header,
memcached_binary_protocol_raw
_response_handler response_handler);
/**
* The different interface levels we support. A pointer is used so the
* size of the structure is fixed. You must ensure that the memory area
* passed as the pointer is valid as long as you use the protocol handle
r.
*/
union {
memcached_binary_protocol_callback_v0_st v0;
/** LIBMEMCACHED_API
* The first version of the callback struct containing all of the memcached_return_t memcached_callback_set(memcached_st *ptr,
* documented commands in the initial release of the binary protocol const memcached_callback_t flag,
* (aka. memcached 1.4.0). void *data);
*/ LIBMEMCACHED_API
memcached_binary_protocol_callback_v1_st v1; void *memcached_callback_get(memcached_st *ptr,
} interface; const memcached_callback_t flag,
} memcached_binary_protocol_callback_st; memcached_return_t *error);
#ifdef __cplusplus
}
#endif #endif
#endif /* __MEMCACHED_CALLBACK_H__ */
 End of changes. 9 change blocks. 
422 lines changed or deleted 21 lines changed or added


 memcached.h   memcached.h 
/* /* 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 * Summary: interface for memcached server
* Description: main include file for libmemcached * Description: main include file for libmemcached
* *
* Copy: See Copyright for the status of this software.
*
* Author: Brian Aker
*/ */
#ifndef __MEMCACHED_H__ #ifndef __MEMCACHED_H__
#define __MEMCACHED_H__ #define __MEMCACHED_H__
#include <stdlib.h> #include <stdlib.h>
#include <inttypes.h> #include <inttypes.h>
#if !defined(__cplusplus) #if !defined(__cplusplus)
# include <stdbool.h> # include <stdbool.h>
#endif #endif
#include <sys/types.h> #include <sys/types.h>
#include <netinet/in.h> #include <netinet/in.h>
#include <libmemcached/visibility.h> #include <libmemcached/visibility.h>
#include <libmemcached/memcached_configure.h> #include <libmemcached/memcached_configure.h>
#include <libmemcached/memcached_constants.h> #include <libmemcached/constants.h>
#include <libmemcached/memcached_types.h> #include <libmemcached/types.h>
#include <libmemcached/memcached_get.h> #include <libmemcached/string.h>
#include <libmemcached/memcached_server.h> #include <libmemcached/stats.h>
#include <libmemcached/memcached_string.h> // Everything above this line must be in the order specified.
#include <libmemcached/memcached_result.h> #include <libmemcached/analyze.h>
#include <libmemcached/memcached_storage.h> #include <libmemcached/auto.h>
#include <libmemcached/behavior.h>
#include <libmemcached/callback.h>
#include <libmemcached/dump.h>
#include <libmemcached/get.h>
#include <libmemcached/result.h>
#include <libmemcached/server.h>
#include <libmemcached/storage.h>
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
#define MEMCACHED_VERSION_STRING_LENGTH 24
#define LIBMEMCACHED_VERSION_STRING "0.35"
struct memcached_analysis_st {
uint32_t average_item_size;
uint32_t longest_uptime;
uint32_t least_free_server;
uint32_t most_consumed_server;
uint32_t oldest_server;
double pool_hit_ratio;
uint64_t most_used_bytes;
uint64_t least_remaining_bytes;
};
struct memcached_stat_st {
uint32_t connection_structures;
uint32_t curr_connections;
uint32_t curr_items;
uint32_t pid;
uint32_t pointer_size;
uint32_t rusage_system_microseconds;
uint32_t rusage_system_seconds;
uint32_t rusage_user_microseconds;
uint32_t rusage_user_seconds;
uint32_t threads;
uint32_t time;
uint32_t total_connections;
uint32_t total_items;
uint32_t uptime;
uint64_t bytes;
uint64_t bytes_read;
uint64_t bytes_written;
uint64_t cmd_get;
uint64_t cmd_set;
uint64_t evictions;
uint64_t get_hits;
uint64_t get_misses;
uint64_t limit_maxbytes;
char version[MEMCACHED_VERSION_STRING_LENGTH];
};
struct memcached_st { struct memcached_st {
uint8_t purging; struct {
bool is_allocated; bool is_allocated:1;
uint8_t distribution; bool is_initialized:1;
uint8_t hash; bool is_purging:1;
} options;
memcached_server_distribution_t distribution;
memcached_hash_t hash;
uint32_t continuum_points_counter; uint32_t continuum_points_counter;
memcached_server_st *hosts; memcached_server_st *hosts;
memcached_server_st *last_disconnected_server; memcached_server_st *last_disconnected_server;
int32_t snd_timeout; int32_t snd_timeout;
int32_t rcv_timeout; int32_t rcv_timeout;
uint32_t server_failure_limit; uint32_t server_failure_limit;
uint32_t io_msg_watermark; uint32_t io_msg_watermark;
uint32_t io_bytes_watermark; uint32_t io_bytes_watermark;
uint32_t io_key_prefetch; uint32_t io_key_prefetch;
uint32_t number_of_hosts; uint32_t number_of_hosts;
uint32_t cursor_server; uint32_t cursor_server;
int cached_errno; int cached_errno;
uint32_t flags; struct {
bool auto_eject_hosts:1;
bool binary_protocol:1;
bool buffer_requests:1;
bool hash_with_prefix_key:1;
bool ketama_weighted:1;
bool no_block:1;
bool no_reply:1;
bool randomize_replica_read:1;
bool reuse_memory:1;
bool support_cas:1;
bool tcp_nodelay:1;
bool use_cache_lookups:1;
bool use_sort_hosts:1;
bool use_udp:1;
bool verify_key:1;
} flags;
int32_t poll_timeout; int32_t poll_timeout;
int32_t connect_timeout; int32_t connect_timeout;
int32_t retry_timeout; int32_t retry_timeout;
uint32_t continuum_count; uint32_t continuum_count;
int send_size; int send_size;
int recv_size; int recv_size;
void *user_data; void *user_data;
time_t next_distribution_rebuild; time_t next_distribution_rebuild;
size_t prefix_key_length; size_t prefix_key_length;
memcached_hash hash_continuum; uint32_t number_of_replicas;
memcached_hash_t distribution_hash;
memcached_result_st result; memcached_result_st result;
memcached_continuum_item_st *continuum; memcached_continuum_item_st *continuum;
memcached_clone_func on_clone; memcached_clone_fn on_clone;
memcached_cleanup_func on_cleanup; memcached_cleanup_fn on_cleanup;
memcached_free_function call_free; memcached_free_fn call_free;
memcached_malloc_function call_malloc; memcached_malloc_fn call_malloc;
memcached_realloc_function call_realloc; memcached_realloc_fn call_realloc;
memcached_calloc_function call_calloc; memcached_calloc_fn call_calloc;
memcached_trigger_key get_key_failure; memcached_trigger_key_fn get_key_failure;
memcached_trigger_delete_key delete_trigger; memcached_trigger_delete_key_fn delete_trigger;
char prefix_key[MEMCACHED_PREFIX_KEY_MAX_SIZE];
uint32_t number_of_replicas;
memcached_callback_st *callbacks; memcached_callback_st *callbacks;
char prefix_key[MEMCACHED_PREFIX_KEY_MAX_SIZE];
}; };
LIBMEMCACHED_API LIBMEMCACHED_API
memcached_return memcached_version(memcached_st *ptr); memcached_return_t memcached_version(memcached_st *ptr);
/* Public API */ /* Public API */
LIBMEMCACHED_API LIBMEMCACHED_API
const char * memcached_lib_version(void); const char * memcached_lib_version(void);
LIBMEMCACHED_API LIBMEMCACHED_API
memcached_st *memcached_create(memcached_st *ptr); memcached_st *memcached_create(memcached_st *ptr);
LIBMEMCACHED_API LIBMEMCACHED_API
void memcached_free(memcached_st *ptr); void memcached_free(memcached_st *ptr);
LIBMEMCACHED_API LIBMEMCACHED_API
memcached_st *memcached_clone(memcached_st *clone, memcached_st *ptr); memcached_st *memcached_clone(memcached_st *clone, memcached_st *ptr);
LIBMEMCACHED_API 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, siz e_t key_length,
time_t expiration); time_t expiration);
LIBMEMCACHED_API LIBMEMCACHED_API
memcached_return memcached_increment(memcached_st *ptr, memcached_return_t memcached_flush(memcached_st *ptr, time_t expiration);
const char *key, size_t key_length,
uint32_t offset,
uint64_t *value);
LIBMEMCACHED_API
memcached_return 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,
const char *master_key, size_t
master_key_length,
const char *key, size_t key_len
gth,
uint64_t offset,
uint64_t *value);
LIBMEMCACHED_API
memcached_return memcached_decrement_by_key(memcached_st *ptr,
const char *master_key, size_t
master_key_length,
const char *key, size_t key_len
gth,
uint64_t offset,
uint64_t *value);
LIBMEMCACHED_API
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);
LIBMEMCACHED_API
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);
LIBMEMCACHED_API
memcached_return memcached_increment_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);
LIBMEMCACHED_API
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);
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);
LIBMEMCACHED_API
memcached_return memcached_stat_servername(memcached_stat_st *memc_stat, ch
ar *args,
char *hostname, unsigned int por
t);
LIBMEMCACHED_API
memcached_return memcached_flush(memcached_st *ptr, time_t expiration);
LIBMEMCACHED_API LIBMEMCACHED_API
memcached_return memcached_verbosity(memcached_st *ptr, unsigned int verbos memcached_return_t memcached_verbosity(memcached_st *ptr, unsigned int verb
ity); osity);
LIBMEMCACHED_API LIBMEMCACHED_API
void memcached_quit(memcached_st *ptr); void memcached_quit(memcached_st *ptr);
LIBMEMCACHED_API LIBMEMCACHED_API
const char *memcached_strerror(memcached_st *ptr, memcached_return rc); const char *memcached_strerror(memcached_st *ptr, memcached_return_t rc);
LIBMEMCACHED_API
memcached_return memcached_behavior_set(memcached_st *ptr, memcached_behavi
or flag, uint64_t data);
LIBMEMCACHED_API
uint64_t memcached_behavior_get(memcached_st *ptr, memcached_behavior flag)
;
/* The two public hash bits */ /* The two public hash bits */
LIBMEMCACHED_API LIBMEMCACHED_API
uint32_t memcached_generate_hash_value(const char *key, size_t key_length, uint32_t memcached_generate_hash_value(const char *key, size_t key_length,
memcached_hash hash_algorithm); memcached_hash_t hash_algorithm);
LIBMEMCACHED_API LIBMEMCACHED_API
uint32_t memcached_generate_hash(memcached_st *ptr, const char *key, size_t key_length); uint32_t memcached_generate_hash(memcached_st *ptr, const char *key, size_t key_length);
LIBMEMCACHED_API LIBMEMCACHED_API
memcached_return memcached_flush_buffers(memcached_st *mem); memcached_return_t memcached_flush_buffers(memcached_st *mem);
/* Server Public functions */ /* Server Public functions */
LIBMEMCACHED_API LIBMEMCACHED_API
memcached_return memcached_server_add_udp(memcached_st *ptr, memcached_return_t memcached_server_add_udp(memcached_st *ptr,
const char *hostname, const char *hostname,
unsigned int port); in_port_t port);
LIBMEMCACHED_API 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); const char *filename);
LIBMEMCACHED_API LIBMEMCACHED_API
memcached_return memcached_server_add(memcached_st *ptr, const char *hostna memcached_return_t memcached_server_add(memcached_st *ptr,
me, const char *hostname, in_port_t por
unsigned int port); t);
LIBMEMCACHED_API 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, const char *hostnam
unsigned int port, e,
uint32_t weight); in_port_t port,
uint32_t weight);
LIBMEMCACHED_API LIBMEMCACHED_API
memcached_return memcached_server_add_unix_socket_with_weight(memcached_st memcached_return_t memcached_server_add_unix_socket_with_weight(memcached_s
*ptr, t *ptr,
const char *f const char
ilename, *filename,
uint32_t weig uint32_t we
ht); ight);
LIBMEMCACHED_API LIBMEMCACHED_API
memcached_return memcached_server_add_with_weight(memcached_st *ptr, const memcached_return_t memcached_server_add_with_weight(memcached_st *ptr, cons
char *hostname, t char *hostname,
unsigned int port, in_port_t port,
uint32_t weight); uint32_t weight);
LIBMEMCACHED_API LIBMEMCACHED_API
void memcached_server_list_free(memcached_server_st *ptr); void memcached_server_list_free(memcached_server_st *ptr);
LIBMEMCACHED_API LIBMEMCACHED_API
memcached_return memcached_server_push(memcached_st *ptr, memcached_server_ st *list); memcached_return_t memcached_server_push(memcached_st *ptr, memcached_serve r_st *list);
LIBMEMCACHED_API LIBMEMCACHED_API
memcached_server_st *memcached_server_list_append(memcached_server_st *ptr, memcached_server_st *memcached_server_list_append(memcached_server_st *ptr,
const char *hostname, const char *hostname,
unsigned int port, in_port_t port,
memcached_return *error); memcached_return_t *error
);
LIBMEMCACHED_API LIBMEMCACHED_API
memcached_server_st *memcached_server_list_append_with_weight(memcached_ser ver_st *ptr, memcached_server_st *memcached_server_list_append_with_weight(memcached_ser ver_st *ptr,
const char *h ostname, const char *h ostname,
unsigned int port, in_port_t por t,
uint32_t weig ht, uint32_t weig ht,
memcached_ret urn *error); memcached_ret urn_t *error);
LIBMEMCACHED_API LIBMEMCACHED_API
unsigned int memcached_server_list_count(memcached_server_st *ptr); unsigned int memcached_server_list_count(memcached_server_st *ptr);
LIBMEMCACHED_API LIBMEMCACHED_API
memcached_server_st *memcached_servers_parse(const char *server_strings); memcached_server_st *memcached_servers_parse(const char *server_strings);
LIBMEMCACHED_API LIBMEMCACHED_API
char *memcached_stat_get_value(memcached_st *ptr, memcached_stat_st *memc_s tat, char *memcached_stat_get_value(memcached_st *ptr, memcached_stat_st *memc_s tat,
const char *key, memcached_return *error); const char *key, memcached_return_t *error);
LIBMEMCACHED_API LIBMEMCACHED_API
char ** memcached_stat_get_keys(memcached_st *ptr, memcached_stat_st *memc_ stat, char ** memcached_stat_get_keys(memcached_st *ptr, memcached_stat_st *memc_ stat,
memcached_return *error); memcached_return_t *error);
LIBMEMCACHED_API LIBMEMCACHED_API
memcached_return memcached_delete_by_key(memcached_st *ptr, memcached_return_t memcached_delete_by_key(memcached_st *ptr,
const char *master_key, size_t mas const char *master_key, size_t m
ter_key_length, aster_key_length,
const char *key, size_t key_length const char *key, size_t key_leng
, th,
time_t expiration); time_t expiration);
LIBMEMCACHED_API LIBMEMCACHED_API
memcached_return memcached_fetch_execute(memcached_st *ptr, memcached_return_t memcached_fetch_execute(memcached_st *ptr,
memcached_execute_function *ca memcached_execute_fn *callback,
llback, void *context,
void *context, unsigned int number_of_callbacks
unsigned int number_of_callbac );
ks);
LIBMEMCACHED_API LIBMEMCACHED_API
memcached_return memcached_callback_set(memcached_st *ptr, memcached_return_t memcached_set_memory_allocators(memcached_st *ptr,
memcached_callback flag, memcached_malloc_fn mem_
void *data); malloc,
LIBMEMCACHED_API memcached_free_fn mem_fr
void *memcached_callback_get(memcached_st *ptr, ee,
memcached_callback flag, memcached_realloc_fn mem
memcached_return *error); _realloc,
memcached_calloc_fn mem_
LIBMEMCACHED_API calloc);
memcached_return memcached_dump(memcached_st *ptr, memcached_dump_func *fun
ction, 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 me
m_free,
memcached_realloc_function
mem_realloc,
memcached_calloc_function
mem_calloc);
LIBMEMCACHED_API LIBMEMCACHED_API
void memcached_get_memory_allocators(memcached_st *ptr, void memcached_get_memory_allocators(memcached_st *ptr,
memcached_malloc_function *mem_malloc, memcached_malloc_fn *mem_malloc,
memcached_free_function *mem_free, memcached_free_fn *mem_free,
memcached_realloc_function *mem_reallo memcached_realloc_fn *mem_realloc,
c, memcached_calloc_fn *mem_calloc);
memcached_calloc_function *mem_calloc)
;
LIBMEMCACHED_API LIBMEMCACHED_API
void *memcached_get_user_data(memcached_st *ptr); void *memcached_get_user_data(memcached_st *ptr);
LIBMEMCACHED_API LIBMEMCACHED_API
void *memcached_set_user_data(memcached_st *ptr, void *data); void *memcached_set_user_data(memcached_st *ptr, void *data);
LIBMEMCACHED_API 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_initiali
zed)
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
#endif /* __MEMCACHED_H__ */ #endif /* __MEMCACHED_H__ */
 End of changes. 39 change blocks. 
233 lines changed or deleted 136 lines changed or added


 memcached.hpp   memcached.hpp 
skipping to change at line 62 skipping to change at line 62
memc(), memc(),
servers(NULL), servers(NULL),
result() result()
{ {
memcached_create(&memc); memcached_create(&memc);
servers= memcached_servers_parse(servers_list.c_str()); servers= memcached_servers_parse(servers_list.c_str());
memcached_server_push(&memc, servers); memcached_server_push(&memc, servers);
} }
Memcache(const std::string &hostname, Memcache(const std::string &hostname,
unsigned int port) in_port_t port)
: :
servers_list(), servers_list(),
memc(), memc(),
servers(NULL), servers(NULL),
result() result()
{ {
memcached_create(&memc); memcached_create(&memc);
servers_list.append(hostname); servers_list.append(hostname);
servers_list.append(":"); servers_list.append(":");
std::ostringstream strsmt; std::ostringstream strsmt;
skipping to change at line 137 skipping to change at line 137
* Get the internal memcached_st * * Get the internal memcached_st *
*/ */
const memcached_st &getImpl() const const memcached_st &getImpl() const
{ {
return memc; return memc;
} }
/** /**
* Return an error string for the given return structure. * 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 . * @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 */ /* first parameter to strerror is unused */
return memcached_strerror(NULL, rc); return memcached_strerror(NULL, 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_t flag) {
return memcached_behavior_get(&memc, flag);
}
/** /**
* Return the string which contains the list of memcached servers being * Return the string which contains the list of memcached servers being
* used. * used.
* *
* @return a std::string containing the list of memcached servers * @return a std::string containing the list of memcached servers
*/ */
const std::string getServersList() const const std::string getServersList() const
{ {
return servers_list; return servers_list;
} }
skipping to change at line 178 skipping to change at line 189
return (servers == NULL); return (servers == NULL);
} }
/** /**
* Add a server to the list of memcached servers to use. * Add a server to the list of memcached servers to use.
* *
* @param[in] server_name name of the server to add * @param[in] server_name name of the server to add
* @param[in] port port number of server to add * @param[in] port port number of server to add
* @return true on success; false otherwise * @return true on success; false otherwise
*/ */
bool addServer(const std::string &server_name, unsigned int port) bool addServer(const std::string &server_name, in_port_t port)
{ {
memcached_return rc; memcached_return_t rc;
std::ostringstream strstm; std::ostringstream strstm;
servers_list.append(","); servers_list.append(",");
servers_list.append(server_name); servers_list.append(server_name);
servers_list.append(":"); servers_list.append(":");
strstm << port; strstm << port;
servers_list.append(strstm.str()); servers_list.append(strstm.str());
servers= memcached_server_list_append(servers, servers= memcached_server_list_append(servers,
server_name.c_str(), server_name.c_str(),
port, port,
&rc); &rc);
skipping to change at line 202 skipping to change at line 213
return (rc == MEMCACHED_SUCCESS); return (rc == MEMCACHED_SUCCESS);
} }
/** /**
* Remove a server from the list of memcached servers to use. * Remove a server from the list of memcached servers to use.
* *
* @param[in] server_name name of the server to remove * @param[in] server_name name of the server to remove
* @param[in] port port number of server to remove * @param[in] port port number of server to remove
* @return true on success; false otherwise * @return true on success; false otherwise
*/ */
bool removeServer(const std::string &server_name, size_t port) bool removeServer(const std::string &server_name, in_port_t port)
{ {
std::string tmp_str; std::string tmp_str;
std::ostringstream strstm; std::ostringstream strstm;
tmp_str.append(","); tmp_str.append(",");
tmp_str.append(server_name); tmp_str.append(server_name);
tmp_str.append(":"); tmp_str.append(":");
strstm << port; strstm << port;
tmp_str.append(strstm.str()); tmp_str.append(strstm.str());
memcached_server_st *server= memcached_servers_parse(tmp_str.c_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); return (rc == MEMCACHED_SUCCESS);
} }
/** /**
* Fetches an individual value from the server. mget() must always * Fetches an individual value from the server. mget() must always
* be called before using this method. * be called before using this method.
* *
* @param[in] key key of object to fetch * @param[in] key key of object to fetch
* @param[out] ret_val store returned object in this vector * @param[out] ret_val store returned object in this vector
* @return a memcached return structure * @return a memcached return structure
*/ */
memcached_return fetch(std::string &key, memcached_return_t fetch(std::string &key,
std::vector<char> &ret_val) std::vector<char> &ret_val)
{ {
char ret_key[MEMCACHED_MAX_KEY]; char ret_key[MEMCACHED_MAX_KEY];
size_t value_length= 0; size_t value_length= 0;
size_t key_length= 0; size_t key_length= 0;
memcached_return rc; memcached_return_t rc;
uint32_t flags= 0; uint32_t flags= 0;
char *value= memcached_fetch(&memc, ret_key, &key_length, char *value= memcached_fetch(&memc, ret_key, &key_length,
&value_length, &flags, &rc); &value_length, &flags, &rc);
if (value && ret_val.empty()) if (value && ret_val.empty())
{ {
ret_val.reserve(value_length); ret_val.reserve(value_length);
ret_val.assign(value, value + value_length); ret_val.assign(value, value + value_length);
key.assign(ret_key); key.assign(ret_key);
free(value); free(value);
} }
skipping to change at line 261 skipping to change at line 272
* *
* @param[in] key key of object whose value to get * @param[in] key key of object whose value to get
* @param[out] ret_val object that is retrieved is stored in * @param[out] ret_val object that is retrieved is stored in
* this vector * this vector
* @return true on success; false otherwise * @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) std::vector<char> &ret_val) throw (Error)
{ {
uint32_t flags= 0; uint32_t flags= 0;
memcached_return rc; memcached_return_t rc;
size_t value_length= 0; size_t value_length= 0;
if (key.empty()) if (key.empty())
{ {
throw(Error("the key supplied is empty!", false)); throw(Error("the key supplied is empty!", false));
} }
char *value= memcached_get(&memc, key.c_str(), key.length(), char *value= memcached_get(&memc, key.c_str(), key.length(),
&value_length, &flags, &rc); &value_length, &flags, &rc);
if (value != NULL && ret_val.empty()) if (value != NULL && ret_val.empty())
{ {
skipping to change at line 297 skipping to change at line 308
* @param[in] key key of object whose value to get * @param[in] key key of object whose value to get
* @param[out] ret_val object that is retrieved is stored in * @param[out] ret_val object that is retrieved is stored in
* this vector * this vector
* @return true on success; false otherwise * @return true on success; false otherwise
*/ */
bool getByKey(const std::string &master_key, bool getByKey(const std::string &master_key,
const std::string &key, const std::string &key,
std::vector<char> &ret_val) throw(Error) std::vector<char> &ret_val) throw(Error)
{ {
uint32_t flags= 0; uint32_t flags= 0;
memcached_return rc; memcached_return_t rc;
size_t value_length= 0; size_t value_length= 0;
if (master_key.empty() || key.empty()) if (master_key.empty() || key.empty())
{ {
throw(Error("the master key or key supplied is empty!", false)); throw(Error("the master key or key supplied is empty!", false));
} }
char *value= memcached_get_by_key(&memc, char *value= memcached_get_by_key(&memc,
master_key.c_str(), master_key.length (), master_key.c_str(), master_key.length (),
key.c_str(), key.length(), key.c_str(), key.length(),
&value_length, &flags, &rc); &value_length, &flags, &rc);
skipping to change at line 353 skipping to change at line 364
key_len.push_back((*it).length()); key_len.push_back((*it).length());
++it; ++it;
} }
/* /*
* 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. * call memcached_mget as we will get undefined behavior.
*/ */
if (! real_keys.empty()) 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()); real_keys.size());
return (rc == MEMCACHED_SUCCESS); return (rc == MEMCACHED_SUCCESS);
} }
return false; return false;
} }
/** /**
* Writes an object to the server. If the object already exists, it will * Writes an object to the server. If the object already exists, it will
* overwrite the existing object. This method always returns true * overwrite the existing object. This method always returns true
skipping to change at line 381 skipping to change at line 392
*/ */
bool set(const std::string &key, bool set(const std::string &key,
const std::vector<char> &value, const std::vector<char> &value,
time_t expiration, time_t expiration,
uint32_t flags) throw(Error) uint32_t flags) throw(Error)
{ {
if (key.empty() || value.empty()) if (key.empty() || value.empty())
{ {
throw(Error("the key or value supplied is empty!", false)); 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(), key.c_str(), key.length(),
&value[0], value.size(), &value[0], value.size(),
expiration, flags); expiration, flags);
return (rc == MEMCACHED_SUCCESS || rc == MEMCACHED_BUFFERED); return (rc == MEMCACHED_SUCCESS || rc == MEMCACHED_BUFFERED);
} }
/** /**
* Writes an object to a server specified by the master_key parameter. * Writes an object to a server specified by the master_key parameter.
* If the object already exists, it will overwrite the existing object. * If the object already exists, it will overwrite the existing object.
* *
skipping to change at line 411 skipping to change at line 422
const std::vector<char> &value, const std::vector<char> &value,
time_t expiration, time_t expiration,
uint32_t flags) throw(Error) uint32_t flags) throw(Error)
{ {
if (master_key.empty() || if (master_key.empty() ||
key.empty() || key.empty() ||
value.empty()) value.empty())
{ {
throw(Error("the key or value supplied is empty!", false)); 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(), master_key.length(),
key.c_str(), key.length(), key.c_str(), key.length(),
&value[0], value.size(), &value[0], value.size(),
expiration, expiration,
flags); flags);
return (rc == MEMCACHED_SUCCESS); return (rc == MEMCACHED_SUCCESS);
} }
/** /**
* Writes a list of objects to the server. Objects are specified by * Writes a list of objects to the server. Objects are specified by
skipping to change at line 505 skipping to change at line 516
* @param[in] offset amount to increment object's value by * @param[in] offset amount to increment object's value by
* @param[out] value store the result of the increment here * @param[out] value store the result of the increment here
* @return true on success; false otherwise * @return true on success; false otherwise
*/ */
bool increment(const std::string &key, uint32_t offset, uint64_t *value) throw(Error) bool increment(const std::string &key, uint32_t offset, uint64_t *value) throw(Error)
{ {
if (key.empty()) if (key.empty())
{ {
throw(Error("the key supplied is empty!", false)); 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.leng th(),
offset, value); offset, value);
return (rc == MEMCACHED_SUCCESS); return (rc == MEMCACHED_SUCCESS);
} }
/** /**
* Decrement the value of the object associated with the specified * Decrement the value of the object associated with the specified
* key by the offset given. The resulting value is saved in the value * key by the offset given. The resulting value is saved in the value
* parameter. * parameter.
* *
* @param[in] key key of object in server whose value to decrement * @param[in] key key of object in server whose value to decrement
skipping to change at line 527 skipping to change at line 538
* @param[out] value store the result of the decrement here * @param[out] value store the result of the decrement here
* @return true on success; false otherwise * @return true on success; false otherwise
*/ */
bool decrement(const std::string &key, uint32_t offset, uint64_t *value) bool decrement(const std::string &key, uint32_t offset, uint64_t *value)
throw(Error) throw(Error)
{ {
if (key.empty()) if (key.empty())
{ {
throw(Error("the key supplied is empty!", false)); 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(), key.length(),
offset, value); offset, value);
return (rc == MEMCACHED_SUCCESS); return (rc == MEMCACHED_SUCCESS);
} }
/** /**
* Add an object with the specified key and value to the server. This * Add an object with the specified key and value to the server. This
* function returns false if the object already exists on the server. * function returns false if the object already exists on the server.
* *
* @param[in] key key of object to add * @param[in] key key of object to add
* @param[in] value of object to add * @param[in] value of object to add
* @return true on success; false otherwise * @return true on success; false otherwise
*/ */
bool add(const std::string &key, const std::vector<char> &value) bool add(const std::string &key, const std::vector<char> &value)
throw(Error) throw(Error)
{ {
if (key.empty() || value.empty()) if (key.empty() || value.empty())
{ {
throw(Error("the key or value supplied is empty!", false)); 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); &value[0], value.size(), 0, 0);
return (rc == MEMCACHED_SUCCESS); return (rc == MEMCACHED_SUCCESS);
} }
/** /**
* Add an object with the specified key and value to the server. This * Add an object with the specified key and value to the server. This
* function returns false if the object already exists on the server. The * function returns false if the object already exists on the server. The
* server to add the object to is specified by the master_key parameter. * server to add the object to is specified by the master_key parameter.
* *
* @param[in[ master_key key of server to add object to * @param[in[ master_key key of server to add object to
skipping to change at line 573 skipping to change at line 584
bool addByKey(const std::string &master_key, bool addByKey(const std::string &master_key,
const std::string &key, const std::string &key,
const std::vector<char> &value) throw(Error) const std::vector<char> &value) throw(Error)
{ {
if (master_key.empty() || if (master_key.empty() ||
key.empty() || key.empty() ||
value.empty()) value.empty())
{ {
throw(Error("the master key or key supplied is empty!", false)); 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.c_str(),
master_key.length(), master_key.length(),
key.c_str(), key.c_str(),
key.length(), key.length(),
&value[0], &value[0],
value.size(), value.size(),
0, 0); 0, 0);
return (rc == MEMCACHED_SUCCESS); return (rc == MEMCACHED_SUCCESS);
} }
skipping to change at line 599 skipping to change at line 610
* @param[in[ value value to replace object with * @param[in[ value value to replace object with
* @return true on success; false otherwise * @return true on success; false otherwise
*/ */
bool replace(const std::string &key, const std::vector<char> &value) thro w(Error) bool replace(const std::string &key, const std::vector<char> &value) thro w(Error)
{ {
if (key.empty() || if (key.empty() ||
value.empty()) value.empty())
{ {
throw(Error("the key or value supplied is empty!", false)); 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(), &value[0], value.size(),
0, 0); 0, 0);
return (rc == MEMCACHED_SUCCESS); return (rc == MEMCACHED_SUCCESS);
} }
/** /**
* Replaces an object on the server. This method only succeeds * Replaces an object on the server. This method only succeeds
* if the object is already present on the server. The server * if the object is already present on the server. The server
* to replace the object on is specified by the master_key param. * to replace the object on is specified by the master_key param.
* *
skipping to change at line 625 skipping to change at line 636
bool replaceByKey(const std::string &master_key, bool replaceByKey(const std::string &master_key,
const std::string &key, const std::string &key,
const std::vector<char> &value) const std::vector<char> &value)
{ {
if (master_key.empty() || if (master_key.empty() ||
key.empty() || key.empty() ||
value.empty()) value.empty())
{ {
throw(Error("the master key or key supplied is empty!", false)); throw(Error("the master key or key supplied is empty!", false));
} }
memcached_return rc= memcached_replace_by_key(&memc, memcached_return_t rc= memcached_replace_by_key(&memc,
master_key.c_str(), master_key.c_str(),
master_key.length(), master_key.length(),
key.c_str(), key.c_str(),
key.length(), key.length(),
&value[0], &value[0],
value.size(), value.size(),
0, 0); 0, 0);
return (rc == MEMCACHED_SUCCESS); return (rc == MEMCACHED_SUCCESS);
} }
skipping to change at line 650 skipping to change at line 661
* @param[in] value data to prepend to object's value * @param[in] value data to prepend to object's value
* @return true on success; false otherwise * @return true on success; false otherwise
*/ */
bool prepend(const std::string &key, const std::vector<char> &value) bool prepend(const std::string &key, const std::vector<char> &value)
throw(Error) throw(Error)
{ {
if (key.empty() || value.empty()) if (key.empty() || value.empty())
{ {
throw(Error("the key or value supplied is empty!", false)); 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); &value[0], value.size(), 0, 0);
return (rc == MEMCACHED_SUCCESS); return (rc == MEMCACHED_SUCCESS);
} }
/** /**
* Places a segment of data before the last piece of data stored. The * Places a segment of data before the last piece of data stored. The
* server on which the object where we will be prepending data is stored * server on which the object where we will be prepending data is stored
* on is specified by the master_key parameter. * on is specified by the master_key parameter.
* *
* @param[in] master_key key of server where object is stored * @param[in] master_key key of server where object is stored
skipping to change at line 676 skipping to change at line 687
const std::string &key, const std::string &key,
const std::vector<char> &value) const std::vector<char> &value)
throw(Error) throw(Error)
{ {
if (master_key.empty() || if (master_key.empty() ||
key.empty() || key.empty() ||
value.empty()) value.empty())
{ {
throw(Error("the master key or key supplied is empty!", false)); 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.c_str(),
master_key.length(), master_key.length(),
key.c_str(), key.c_str(),
key.length(), key.length(),
&value[0], &value[0],
value.size(), value.size(),
0, 0,
0); 0);
return (rc == MEMCACHED_SUCCESS); return (rc == MEMCACHED_SUCCESS);
} }
skipping to change at line 702 skipping to change at line 713
* @param[in] value data to append to object's value * @param[in] value data to append to object's value
* @return true on success; false otherwise * @return true on success; false otherwise
*/ */
bool append(const std::string &key, const std::vector<char> &value) bool append(const std::string &key, const std::vector<char> &value)
throw(Error) throw(Error)
{ {
if (key.empty() || value.empty()) if (key.empty() || value.empty())
{ {
throw(Error("the key or value supplied is empty!", false)); 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.c_str(),
key.length(), key.length(),
&value[0], &value[0],
value.size(), value.size(),
0, 0); 0, 0);
return (rc == MEMCACHED_SUCCESS); return (rc == MEMCACHED_SUCCESS);
} }
/** /**
* Places a segment of data at the end of the last piece of data stored. The * Places a segment of data at the end of the last piece of data stored. The
skipping to change at line 732 skipping to change at line 743
const std::string &key, const std::string &key,
const std::vector<char> &value) const std::vector<char> &value)
throw(Error) throw(Error)
{ {
if (master_key.empty() || if (master_key.empty() ||
key.empty() || key.empty() ||
value.empty()) value.empty())
{ {
throw(Error("the master key or key supplied is empty!", false)); throw(Error("the master key or key supplied is empty!", false));
} }
memcached_return rc= memcached_append_by_key(&memc, memcached_return_t rc= memcached_append_by_key(&memc,
master_key.c_str(), master_key.c_str(),
master_key.length(), master_key.length(),
key.c_str(), key.c_str(),
key.length(), key.length(),
&value[0], &value[0],
value.size(), value.size(),
0, 0); 0, 0);
return (rc == MEMCACHED_SUCCESS); return (rc == MEMCACHED_SUCCESS);
} }
skipping to change at line 759 skipping to change at line 770
* @param[in] cas_arg "cas" value * @param[in] cas_arg "cas" value
*/ */
bool cas(const std::string &key, bool cas(const std::string &key,
const std::vector<char> &value, const std::vector<char> &value,
uint64_t cas_arg) throw(Error) uint64_t cas_arg) throw(Error)
{ {
if (key.empty() || value.empty()) if (key.empty() || value.empty())
{ {
throw(Error("the key or value supplied is empty!", false)); throw(Error("the key or value supplied is empty!", false));
} }
memcached_return rc= memcached_cas(&memc, key.c_str(), key.length(), memcached_return_t rc= memcached_cas(&memc, key.c_str(), key.length(),
&value[0], value.size(), &value[0], value.size(),
0, 0, cas_arg); 0, 0, cas_arg);
return (rc == MEMCACHED_SUCCESS); return (rc == MEMCACHED_SUCCESS);
} }
/** /**
* Overwrite data in the server as long as the cas_arg value * Overwrite data in the server as long as the cas_arg value
* is still the same in the server. The server to use is * is still the same in the server. The server to use is
* specified by the master_key parameter. * specified by the master_key parameter.
* *
skipping to change at line 786 skipping to change at line 797
const std::string &key, const std::string &key,
const std::vector<char> &value, const std::vector<char> &value,
uint64_t cas_arg) throw(Error) uint64_t cas_arg) throw(Error)
{ {
if (master_key.empty() || if (master_key.empty() ||
key.empty() || key.empty() ||
value.empty()) value.empty())
{ {
throw(Error("the master key, key or value supplied is empty!", false) ); throw(Error("the master key, key or value supplied is empty!", false) );
} }
memcached_return rc= memcached_cas_by_key(&memc, memcached_return_t rc= memcached_cas_by_key(&memc,
master_key.c_str(), master_key.c_str(),
master_key.length(), master_key.length(),
key.c_str(), key.c_str(),
key.length(), key.length(),
&value[0], &value[0],
value.size(), value.size(),
0, 0, cas_arg); 0, 0, cas_arg);
return (rc == MEMCACHED_SUCCESS); return (rc == MEMCACHED_SUCCESS);
} }
skipping to change at line 809 skipping to change at line 820
* *
* @param[in] key key of object to delete * @param[in] key key of object to delete
* @return true on success; false otherwise * @return true on success; false otherwise
*/ */
bool remove(const std::string &key) throw(Error) bool remove(const std::string &key) throw(Error)
{ {
if (key.empty()) if (key.empty())
{ {
throw(Error("the key supplied is empty!", false)); 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); return (rc == MEMCACHED_SUCCESS);
} }
/** /**
* Delete an object from the server specified by the key given. * Delete an object from the server specified by the key given.
* *
* @param[in] key key of object to delete * @param[in] key key of object to delete
* @param[in] expiration time to delete the object after * @param[in] expiration time to delete the object after
* @return true on success; false otherwise * @return true on success; false otherwise
*/ */
bool remove(const std::string &key, bool remove(const std::string &key,
time_t expiration) throw(Error) time_t expiration) throw(Error)
{ {
if (key.empty()) if (key.empty())
{ {
throw(Error("the key supplied is empty!", false)); 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.c_str(),
key.length(), key.length(),
expiration); expiration);
return (rc == MEMCACHED_SUCCESS); return (rc == MEMCACHED_SUCCESS);
} }
/** /**
* 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] master_key specifies server to remove object from
* @param[in] key key of object to delete * @param[in] key key of object to delete
* @return true on success; false otherwise * @return true on success; false otherwise
*/ */
bool removeByKey(const std::string &master_key, bool removeByKey(const std::string &master_key,
const std::string &key) throw(Error) const std::string &key) throw(Error)
{ {
if (master_key.empty() || key.empty()) if (master_key.empty() || key.empty())
{ {
throw(Error("the master key or key supplied is empty!", false)); 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.c_str(),
master_key.length(), master_key.length(),
key.c_str(), key.c_str(),
key.length(), key.length(),
0); 0);
return (rc == MEMCACHED_SUCCESS); return (rc == MEMCACHED_SUCCESS);
} }
/** /**
* Delete an object from the server specified by the key given. * Delete an object from the server specified by the key given.
skipping to change at line 873 skipping to change at line 884
* @return true on success; false otherwise * @return true on success; false otherwise
*/ */
bool removeByKey(const std::string &master_key, bool removeByKey(const std::string &master_key,
const std::string &key, const std::string &key,
time_t expiration) throw(Error) time_t expiration) throw(Error)
{ {
if (master_key.empty() || key.empty()) if (master_key.empty() || key.empty())
{ {
throw(Error("the master key or key supplied is empty!", false)); 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.c_str(),
master_key.length(), master_key.length(),
key.c_str(), key.c_str(),
key.length(), key.length(),
expiration); expiration);
return (rc == MEMCACHED_SUCCESS); return (rc == MEMCACHED_SUCCESS);
} }
/** /**
* Wipe the contents of memcached servers. * Wipe the contents of memcached servers.
* *
* @param[in] expiration time to wait until wiping contents of * @param[in] expiration time to wait until wiping contents of
* memcached servers * memcached servers
* @return true on success; false otherwise * @return true on success; false otherwise
*/ */
bool flush(time_t expiration) bool flush(time_t expiration)
{ {
memcached_return rc= memcached_flush(&memc, expiration); memcached_return_t rc= memcached_flush(&memc, expiration);
return (rc == MEMCACHED_SUCCESS); return (rc == MEMCACHED_SUCCESS);
} }
/** /**
* Callback function for result sets. It passes the result * Callback function for result sets. It passes the result
* sets to the list of functions provided. * sets to the list of functions provided.
* *
* @param[in] callback list of callback functions * @param[in] callback list of callback functions
* @param[in] context pointer to memory reference that is * @param[in] context pointer to memory reference that is
* supplied to the calling function * supplied to the calling function
* @param[in] num_of_callbacks number of callback functions * @param[in] num_of_callbacks number of callback functions
* @return true on success; false otherwise * @return true on success; false otherwise
*/ */
bool fetchExecute(memcached_execute_function *callback, bool fetchExecute(memcached_execute_fn *callback,
void *context, 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, callback,
context, context,
num_of_callbacks); num_of_callbacks);
return (rc == MEMCACHED_SUCCESS); return (rc == MEMCACHED_SUCCESS);
} }
/** /**
* Get the library version string. * Get the library version string.
* @return std::string containing a copy of the library version string. * @return std::string containing a copy of the library version string.
*/ */
skipping to change at line 938 skipping to change at line 949
* Retrieve memcached statistics. Populate a std::map with the retrieved * Retrieve memcached statistics. Populate a std::map with the retrieved
* stats. Each server will map to another std::map of the key:value stats . * stats. Each server will map to another std::map of the key:value stats .
* *
* @param[out] stats_map a std::map to be populated with the memcached * @param[out] stats_map a std::map to be populated with the memcached
* stats * stats
* @return true on success; false otherwise * @return true on success; false otherwise
*/ */
bool getStats(std::map< std::string, std::map<std::string, std::string> > bool getStats(std::map< std::string, std::map<std::string, std::string> >
&stats_map) &stats_map)
{ {
memcached_return rc; memcached_return_t rc;
memcached_stat_st *stats= memcached_stat(&memc, NULL, &rc); memcached_stat_st *stats= memcached_stat(&memc, NULL, &rc);
if (rc != MEMCACHED_SUCCESS && if (rc != MEMCACHED_SUCCESS &&
rc != MEMCACHED_SOME_ERRORS) rc != MEMCACHED_SOME_ERRORS)
{ {
return false; return false;
} }
uint32_t server_count= memcached_server_count(&memc); uint32_t server_count= memcached_server_count(&memc);
 End of changes. 36 change blocks. 
35 lines changed or deleted 46 lines changed or added


 memcached_configure.h   memcached_configure.h 
skipping to change at line 16 skipping to change at line 16
* Author: Trond Norbye * Author: Trond Norbye
*/ */
#ifndef MEMCACHED_CONFIGURE_H #ifndef MEMCACHED_CONFIGURE_H
#define MEMCACHED_CONFIGURE_H #define MEMCACHED_CONFIGURE_H
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
#define LIBMEMCACHED_VERSION_STRING "0.36"
#define LIBMEMCACHED_VERSION_HEX 0x00036000
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
#endif /* MEMCACHED_CONFIGURE_H */ #endif /* MEMCACHED_CONFIGURE_H */
 End of changes. 1 change blocks. 
0 lines changed or deleted 3 lines changed or added


 memcached_util.h   memcached_util.h 
/* /* LibMemcached
* Summary: interface for libmemcached utility library * Copyright (C) 2006-2009 Brian Aker
* Description: main include file for libmemcachedutil * 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: Connection pool library.
* *
* Author: Trond Norbye * Author: Trond Norbye
*
*/ */
#ifndef MEMCACHED_UTIL_H #ifndef MEMCACHED_UTIL_H
#define MEMCACHED_UTIL_H #define MEMCACHED_UTIL_H
#include <libmemcached/memcached_pool.h> #include <libmemcached/util/pool.h>
#endif /* MEMCACHED_UTIL_H */ #endif /* MEMCACHED_UTIL_H */
 End of changes. 4 change blocks. 
5 lines changed or deleted 9 lines changed or added


 protocol_handler.h   protocol_handler.h 
/* /* LibMemcached
* Summary: Definition of the callback interface to the protocol handler * 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: Definition of the callback interface to the protocol handler
* *
* Author: Trond Norbye * Author: Trond Norbye
*
*/ */
#ifndef MEMCACHED_PROTOCOL_H #ifndef MEMCACHED_PROTOCOL_H
#define MEMCACHED_PROTOCOL_H #define MEMCACHED_PROTOCOL_H
#include <sys/types.h> #include <sys/types.h>
#include <stdbool.h> #include <stdbool.h>
#include <libmemcached/memcached/protocol_binary.h> #include <libmemcached/memcached/protocol_binary.h>
#include <libmemcached/visibility.h> #include <libmemcached/visibility.h>
#include <libmemcached/protocol/callback.h> #include <libmemcached/protocol/callback.h>
 End of changes. 4 change blocks. 
3 lines changed or deleted 9 lines changed or added


 visibility.h   visibility.h 
/* /*
* Summary: interface for memcached server * Summary: interface for HashKit functions
* Description: visibitliy macros for libmemcached * Description: visibitliy macros for HashKit library
* *
* Use and distribution licensed under the BSD license. See * Use and distribution licensed under the BSD license. See
* the COPYING file in this directory for full text. * the COPYING file in this directory for full text.
* *
* Author: Monty Taylor * Author: Monty Taylor
*/ */
/** /**
* @file * @file
* @brief Visibility control macros * @brief Visibility control macros
*/ */
#ifndef __LIBMEMCACHED_VISIBILITY_H #ifndef HASHKIT_VISIBILITY_H
#define __LIBMEMCACHED_VISIBILITY_H #define HASHKIT_VISIBILITY_H
/** /**
* *
* LIBMEMCACHED_API is used for the public API symbols. It either DLL impor ts or * HASHKIT_API is used for the public API symbols. It either DLL imports or
* DLL exports (or does nothing for static build). * DLL exports (or does nothing for static build).
* *
* LIBMEMCACHED_LOCAL is used for non-api symbols. * HASHKIT_LOCAL is used for non-api symbols.
*/ */
#if defined(BUILDING_LIBMEMCACHED) #if defined(BUILDING_HASHKIT)
# if defined(HAVE_VISIBILITY) && HAVE_VISIBILITY # if defined(HAVE_VISIBILITY) && HAVE_VISIBILITY
# define LIBMEMCACHED_API __attribute__ ((visibility("default"))) # define HASHKIT_API __attribute__ ((visibility("default")))
# define LIBMEMCACHED_LOCAL __attribute__ ((visibility("hidden"))) # define HASHKIT_LOCAL __attribute__ ((visibility("hidden")))
# elif defined (__SUNPRO_C) && (__SUNPRO_C >= 0x550) # elif defined (__SUNPRO_C) && (__SUNPRO_C >= 0x550)
# define LIBMEMCACHED_API __global # define HASHKIT_API __global
# define LIBMEMCACHED_LOCAL __hidden # define HASHKIT_LOCAL __hidden
# elif defined(_MSC_VER) # elif defined(_MSC_VER)
# define LIBMEMCACHED_API extern __declspec(dllexport) # define HASHKIT_API extern __declspec(dllexport)
# define LIBMEMCACHED_LOCAL # define HASHKIT_LOCAL
# else # else
# define LIBMEMCACHED_API # define HASHKIT_API
# define LIBMEMCACHED_LOCAL # define HASHKIT_LOCAL
# endif /* defined(HAVE_VISIBILITY) */ # endif /* defined(HAVE_VISIBILITY) */
#else /* defined(BUILDING_LIBMEMCACHED) */ #else /* defined(BUILDING_HASHKIT) */
# if defined(_MSC_VER) # if defined(_MSC_VER)
# define LIBMEMCACHED_API extern __declspec(dllimport) # define HASHKIT_API extern __declspec(dllimport)
# define LIBMEMCACHED_LOCAL # define HASHKIT_LOCAL
# else # else
# define LIBMEMCACHED_API # define HASHKIT_API
# define LIBMEMCACHED_LOCAL # define HASHKIT_LOCAL
# endif /* defined(_MSC_VER) */ # endif /* defined(_MSC_VER) */
#endif /* defined(BUILDING_LIBMEMCACHED) */ #endif /* defined(BUILDING_HASHKIT) */
#endif /* __LIBMEMCACHED_VISIBILITY_H */ #endif /* HASHKIT_VISIBILITY_H */
 End of changes. 14 change blocks. 
21 lines changed or deleted 21 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/