Apache2
Memcached Client Routines
Collaboration diagram for Memcached Client Routines:

Data Structures

struct  apr_memcache_server_t
 
struct  apr_memcache_t
 
struct  apr_memcache_value_t
 
struct  apr_memcache_stats_t
 

Typedefs

typedef struct apr_memcache_conn_t apr_memcache_conn_t
 
typedef struct apr_memcache_server_t apr_memcache_server_t
 
typedef apr_uint32_t(* apr_memcache_hash_func) (void *baton, const char *data, const apr_size_t data_len)
 
typedef struct apr_memcache_t apr_memcache_t
 
typedef apr_memcache_server_t *(* apr_memcache_server_func) (void *baton, apr_memcache_t *mc, const apr_uint32_t hash)
 

Enumerations

enum  apr_memcache_server_status_t { APR_MC_SERVER_LIVE , APR_MC_SERVER_DEAD }
 

Functions

apr_uint32_t apr_memcache_hash (apr_memcache_t *mc, const char *data, const apr_size_t data_len)
 
apr_uint32_t apr_memcache_hash_crc32 (void *baton, const char *data, const apr_size_t data_len)
 
apr_uint32_t apr_memcache_hash_default (void *baton, const char *data, const apr_size_t data_len)
 
apr_memcache_server_tapr_memcache_find_server_hash (apr_memcache_t *mc, const apr_uint32_t hash)
 
apr_memcache_server_tapr_memcache_find_server_hash_default (void *baton, apr_memcache_t *mc, const apr_uint32_t hash)
 
apr_status_t apr_memcache_add_server (apr_memcache_t *mc, apr_memcache_server_t *server)
 
apr_memcache_server_tapr_memcache_find_server (apr_memcache_t *mc, const char *host, apr_port_t port)
 
apr_status_t apr_memcache_enable_server (apr_memcache_t *mc, apr_memcache_server_t *ms)
 
apr_status_t apr_memcache_disable_server (apr_memcache_t *mc, apr_memcache_server_t *ms)
 
void apr_memcache_set_retry_period (apr_memcache_t *mc, apr_time_t retry_period)
 
apr_time_t apr_memcache_get_retry_period (apr_memcache_t *mc)
 
apr_status_t apr_memcache_server_create (apr_pool_t *p, const char *host, apr_port_t port, int min, int smax, int max, apr_interval_time_t ttl, apr_memcache_server_t **ns)
 
apr_status_t apr_memcache_create (apr_pool_t *p, apr_uint16_t max_servers, apr_uint32_t flags, apr_memcache_t **mc)
 
apr_status_t apr_memcache_getp (apr_memcache_t *mc, apr_pool_t *p, const char *key, char **baton, apr_size_t *len, apr_uint16_t *flags)
 
void apr_memcache_add_multget_key (apr_pool_t *data_pool, const char *key, apr_hash_t **values)
 
apr_status_t apr_memcache_multgetp (apr_memcache_t *mc, apr_pool_t *temp_pool, apr_pool_t *data_pool, apr_hash_t *values)
 
apr_status_t apr_memcache_set (apr_memcache_t *mc, const char *key, char *baton, const apr_size_t data_size, apr_uint32_t timeout, apr_uint16_t flags)
 
apr_status_t apr_memcache_add (apr_memcache_t *mc, const char *key, char *baton, const apr_size_t data_size, apr_uint32_t timeout, apr_uint16_t flags)
 
apr_status_t apr_memcache_replace (apr_memcache_t *mc, const char *key, char *baton, const apr_size_t data_size, apr_uint32_t timeout, apr_uint16_t flags)
 
apr_status_t apr_memcache_delete (apr_memcache_t *mc, const char *key, apr_uint32_t timeout)
 
apr_status_t apr_memcache_incr (apr_memcache_t *mc, const char *key, apr_int32_t n, apr_uint32_t *nv)
 
apr_status_t apr_memcache_decr (apr_memcache_t *mc, const char *key, apr_int32_t n, apr_uint32_t *new_value)
 
apr_status_t apr_memcache_version (apr_memcache_server_t *ms, apr_pool_t *p, char **baton)
 
apr_status_t apr_memcache_stats (apr_memcache_server_t *ms, apr_pool_t *p, apr_memcache_stats_t **stats)
 

Detailed Description

Typedef Documentation

◆ apr_memcache_conn_t

Opaque memcache client connection object

◆ apr_memcache_hash_func

typedef apr_uint32_t(* apr_memcache_hash_func) (void *baton, const char *data, const apr_size_t data_len)

◆ apr_memcache_server_func

typedef apr_memcache_server_t*(* apr_memcache_server_func) (void *baton, apr_memcache_t *mc, const apr_uint32_t hash)

◆ apr_memcache_server_t

Memcache Server Info Object

◆ apr_memcache_t

Enumeration Type Documentation

◆ apr_memcache_server_status_t

Specifies the status of a memcached server

Enumerator
APR_MC_SERVER_LIVE 

Server is alive and responding to requests

APR_MC_SERVER_DEAD 

Server is not responding to requests

Function Documentation

◆ apr_memcache_add()

apr_status_t apr_memcache_add ( apr_memcache_t mc,
const char *  key,
char *  baton,
const apr_size_t  data_size,
apr_uint32_t  timeout,
apr_uint16_t  flags 
)

Adds value by key on the server

Parameters
mcclient to use
keynull terminated string containing the key
batondata to store on the server
data_sizelength of data at baton
timeouttime for the data to live on the server
flagsany flags set by the client for this key
Returns
APR_SUCCESS if the key was added, APR_EEXIST if the key already exists on the server.

◆ apr_memcache_add_multget_key()

void apr_memcache_add_multget_key ( apr_pool_t data_pool,
const char *  key,
apr_hash_t **  values 
)

Add a key to a hash for a multiget query if the hash (*value) is NULL it will be created

Parameters
data_poolpool from where the hash and their items are created from
keynull terminated string containing the key
valueshash of keys and values that this key will be added to
Returns

◆ apr_memcache_add_server()

apr_status_t apr_memcache_add_server ( apr_memcache_t mc,
apr_memcache_server_t server 
)

Adds a server to a client object

Parameters
mcThe memcache client object to use
serverServer to add
Remarks
Adding servers is not thread safe, and should be done once at startup.
Warning
Changing servers after startup may cause keys to go to different servers.

◆ apr_memcache_create()

apr_status_t apr_memcache_create ( apr_pool_t p,
apr_uint16_t  max_servers,
apr_uint32_t  flags,
apr_memcache_t **  mc 
)

Creates a new memcached client object

Parameters
pPool to use
max_serversmaximum number of servers
flagsNot currently used
mclocation of the new memcache client object

◆ apr_memcache_decr()

apr_status_t apr_memcache_decr ( apr_memcache_t mc,
const char *  key,
apr_int32_t  n,
apr_uint32_t new_value 
)

Decrements a value

Parameters
mcclient to use
keynull terminated string containing the key
nnumber to decrement by
new_valuenew value after decrementing

◆ apr_memcache_delete()

apr_status_t apr_memcache_delete ( apr_memcache_t mc,
const char *  key,
apr_uint32_t  timeout 
)

Deletes a key from a server

Parameters
mcclient to use
keynull terminated string containing the key
timeouttime for the delete to stop other clients from adding

◆ apr_memcache_disable_server()

apr_status_t apr_memcache_disable_server ( apr_memcache_t mc,
apr_memcache_server_t ms 
)

Disable a Server

Parameters
mcThe memcache client object to use
msServer to Disable

◆ apr_memcache_enable_server()

apr_status_t apr_memcache_enable_server ( apr_memcache_t mc,
apr_memcache_server_t ms 
)

Enables a Server for use again

Parameters
mcThe memcache client object to use
msServer to Activate

◆ apr_memcache_find_server()

apr_memcache_server_t* apr_memcache_find_server ( apr_memcache_t mc,
const char *  host,
apr_port_t  port 
)

Finds a Server object based on a hostname/port pair

Parameters
mcThe memcache client object to use
hostHostname of the server
portPort of the server
Returns
Server with matching Hostname and Port, or NULL if none was found.

◆ apr_memcache_find_server_hash()

apr_memcache_server_t* apr_memcache_find_server_hash ( apr_memcache_t mc,
const apr_uint32_t  hash 
)

Picks a server based on a hash

Parameters
mcThe memcache client object to use
hashHashed value of a Key
Returns
server that controls specified hash
See also
apr_memcache_hash

◆ apr_memcache_find_server_hash_default()

apr_memcache_server_t* apr_memcache_find_server_hash_default ( void *  baton,
apr_memcache_t mc,
const apr_uint32_t  hash 
)

server selection compatible with the standard Perl Client.

◆ apr_memcache_get_retry_period()

apr_time_t apr_memcache_get_retry_period ( apr_memcache_t mc)

Get the retry period for retrying a dead server

Parameters
mcThe memcache client object to use
Returns
retry_period Period that must have passed until a server that was declared dead is retried.

◆ apr_memcache_getp()

apr_status_t apr_memcache_getp ( apr_memcache_t mc,
apr_pool_t p,
const char *  key,
char **  baton,
apr_size_t len,
apr_uint16_t flags 
)

Gets a value from the server, allocating the value out of p

Parameters
mcclient to use
pPool to use
keynull terminated string containing the key
batonlocation of the allocated value
lenlength of data at baton
flagsany flags set by the client for this key
Returns

◆ apr_memcache_hash()

apr_uint32_t apr_memcache_hash ( apr_memcache_t mc,
const char *  data,
const apr_size_t  data_len 
)

Creates a crc32 hash used to split keys between servers

Parameters
mcThe memcache client object to use
dataData to be hashed
data_lenLength of the data to use
Returns
crc32 hash of data
Remarks
The crc32 hash is not compatible with old memcached clients.

◆ apr_memcache_hash_crc32()

apr_uint32_t apr_memcache_hash_crc32 ( void *  baton,
const char *  data,
const apr_size_t  data_len 
)

Pure CRC32 Hash. Used by some clients.

◆ apr_memcache_hash_default()

apr_uint32_t apr_memcache_hash_default ( void *  baton,
const char *  data,
const apr_size_t  data_len 
)

hash compatible with the standard Perl Client.

◆ apr_memcache_incr()

apr_status_t apr_memcache_incr ( apr_memcache_t mc,
const char *  key,
apr_int32_t  n,
apr_uint32_t nv 
)

Increments a value

Parameters
mcclient to use
keynull terminated string containing the key
nnumber to increment by
nvnew value after incrementing

◆ apr_memcache_multgetp()

apr_status_t apr_memcache_multgetp ( apr_memcache_t mc,
apr_pool_t temp_pool,
apr_pool_t data_pool,
apr_hash_t values 
)

Gets multiple values from the server, allocating the values out of p

Parameters
mcclient to use
temp_poolPool used for temporary allocations. May be cleared inside this call.
data_poolPool used to allocate data for the returned values.
valueshash of apr_memcache_value_t keyed by strings, contains the result of the multiget call.
Returns

◆ apr_memcache_replace()

apr_status_t apr_memcache_replace ( apr_memcache_t mc,
const char *  key,
char *  baton,
const apr_size_t  data_size,
apr_uint32_t  timeout,
apr_uint16_t  flags 
)

Replaces value by key on the server

Parameters
mcclient to use
keynull terminated string containing the key
batondata to store on the server
data_sizelength of data at baton
timeouttime for the data to live on the server
flagsany flags set by the client for this key
Returns
APR_SUCCESS if the key was added, APR_EEXIST if the key did not exist on the server.

◆ apr_memcache_server_create()

apr_status_t apr_memcache_server_create ( apr_pool_t p,
const char *  host,
apr_port_t  port,
int  min,
int  smax,
int  max,
apr_interval_time_t  ttl,
apr_memcache_server_t **  ns 
)

Creates a new Server Object

Parameters
pPool to use
hosthostname of the server
portport of the server
minminimum number of client sockets to open
smaxsoft maximum number of client connections to open
maxhard maximum number of client connections
ttltime to live in microseconds of a client connection
nslocation of the new server object
See also
apr_reslist_create
Remarks
min, smax, and max are only used when APR_HAS_THREADS

◆ apr_memcache_set()

apr_status_t apr_memcache_set ( apr_memcache_t mc,
const char *  key,
char *  baton,
const apr_size_t  data_size,
apr_uint32_t  timeout,
apr_uint16_t  flags 
)

Sets a value by key on the server

Parameters
mcclient to use
keynull terminated string containing the key
batondata to store on the server
data_sizelength of data at baton
timeouttime in seconds for the data to live on the server
flagsany flags set by the client for this key

◆ apr_memcache_set_retry_period()

void apr_memcache_set_retry_period ( apr_memcache_t mc,
apr_time_t  retry_period 
)

Set the retry period for retrying a dead server

Parameters
mcThe memcache client object to use
retry_periodPeriod that must have passed until a server that was declared dead is retried.

◆ apr_memcache_stats()

apr_status_t apr_memcache_stats ( apr_memcache_server_t ms,
apr_pool_t p,
apr_memcache_stats_t **  stats 
)

Query a server for statistics

Parameters
msserver to query
pPool to allocate answer from
statslocation of the new statistics structure

◆ apr_memcache_version()

apr_status_t apr_memcache_version ( apr_memcache_server_t ms,
apr_pool_t p,
char **  baton 
)

Query a server's version

Parameters
msserver to query
pPool to allocate answer from
batonlocation to store server version string