36#if APU_MAJOR_VERSION > 1 || \
37 (APU_MAJOR_VERSION == 1 && APU_MINOR_VERSION > 5)
38#define HAVE_APU_REDIS 1
44#ifndef RD_DEFAULT_SERVER_PORT
45#define RD_DEFAULT_SERVER_PORT 6379
49#ifndef RD_DEFAULT_SERVER_MIN
50#define RD_DEFAULT_SERVER_MIN 0
53#ifndef RD_DEFAULT_SERVER_SMAX
54#define RD_DEFAULT_SERVER_SMAX 1
57#ifndef RD_DEFAULT_SERVER_TTL
58#define RD_DEFAULT_SERVER_TTL apr_time_from_sec(15)
61#ifndef RD_DEFAULT_SERVER_RWTO
62#define RD_DEFAULT_SERVER_RWTO apr_time_from_sec(5)
65module AP_MODULE_DECLARE_DATA socache_redis_module;
85 return "List of server names required to create redis socache.";
94 const char *
namespace,
106 &socache_redis_module);
121 "Failed to create Redis Object of '%d' size.",
138 "Failed to Parse redis Server: '%s'", split);
144 "Failed to Parse Server, "
145 "no hostname specified: '%s'", split);
163 "Failed to Create redis Server: %s:%d",
171 "Failed to Add redis Server: %s:%d",
180 ctx->taglen = strlen(
ctx->tag) + 1;
197 const unsigned char *
id,
unsigned int idlen,
212 const unsigned char *
id,
unsigned int idlen,
214 unsigned char *
ucaData,
unsigned int nData,
233 "scache_rd: error setting key '%s' "
234 "with %d bytes of data",
buf, nData);
242 const unsigned char *
id,
unsigned int idlen,
261 "scache_rd: 'retrieve' FAIL");
267 "scache_rd: 'retrieve' OVERFLOW");
278 const unsigned char *
id,
292 "scache_rd: error deleting key '%s' ",
320 ap_rprintf(
r,
"<b>General::</b> Version: <i>%u.%u.%u</i> [%u bits], PID: <i>%u</i>, Uptime: <i>%u hrs</i> <br />\n",
322 stats->process_id,
stats->uptime_in_seconds/3600);
323 ap_rprintf(
r,
"<b>Clients::</b> Connected: <i>%d</i>, Blocked: <i>%d</i> <br />\n",
324 stats->connected_clients,
stats->blocked_clients);
327 ap_rprintf(
r,
"<b>CPU::</b> System: <i>%u</i>, User: <i>%u</i><br />\n",
330 stats->total_connections_received,
stats->total_commands_processed,
331 stats->rejected_connections);
333 stats->keyspace_hits,
stats->keyspace_misses);
335 stats->total_net_input_bytes,
stats->total_net_output_bytes);
342 ap_rprintf(
r,
"<b>Misc::</b> Role: <i>%s</i>, Connected Slaves: <i>%u</i>, Is Cluster?: <i>%s</i> \n",
343 role,
stats->connected_clients,
344 (
stats->cluster_enabled ?
"yes" :
"no"));
348 ap_rprintf(
r,
"Version: %u.%u.%u [%u bits], PID: %u, Uptime: %u hrs %s\n",
351 ap_rprintf(
r,
"Clients:: Connected: %d, Blocked: %d %s\n",
359 stats->total_connections_received,
stats->total_commands_processed,
360 stats->rejected_connections,
br);
364 stats->total_net_input_bytes,
stats->total_net_output_bytes,
br);
371 ap_rprintf(
r,
"Misc:: Role: %s, Connected Slaves: %u, Is Cluster?: %s %s\n",
372 role,
stats->connected_clients,
373 (
stats->cluster_enabled ?
"yes" :
"no"),
br);
417 &socache_redis_module);
421 " has wrong format",
NULL);
426 " can only be 0 or up to one hour.",
NULL);
440 &socache_redis_module);
444 " has wrong format",
NULL);
449 " can only be 0 or up to one hour.",
NULL);
471 "TTL used for the connection pool with the Redis server(s)"),
473 "R/W timeout used for the connection with the Redis server(s)"),
Apache Multi-Processing Module library.
Small object cache provider interface.
apr_redis_delete(apr_redis_t *rc, const char *key, apr_uint32_t timeout)
apr_redis_stats(apr_redis_server_t *rs, apr_pool_t *p, apr_redis_stats_t **stats)
Client interface for redis.
APR-util Versioning Interface.
#define AP_INIT_TAKE1(directive, func, mconfig, where, help)
#define ap_get_module_config(v, m)
#define AP_DECLARE_MODULE(foo)
const unsigned char * buf
int ap_rprintf(request_rec *r, const char *fmt,...) __attribute__((format(printf
static APR_INLINE int ap_rputs(const char *str, request_rec *r)
apr_status_t ap_register_provider(apr_pool_t *pool, const char *provider_group, const char *provider_name, const char *provider_version, const void *provider)
const char apr_port_t port
apr_brigade_flush void * ctx
const char apr_ssize_t int flags
const char const apr_size_t data_len
apr_pool_t apr_memcache_stats_t ** stats
const char apr_port_t apr_uint32_t apr_uint32_t apr_uint32_t apr_uint32_t apr_uint32_t rwto
apr_status_t() ap_socache_iterator_t(ap_socache_instance_t *instance, server_rec *s, void *userctx, const unsigned char *id, unsigned int idlen, const unsigned char *data, unsigned int datalen, apr_pool_t *pool)
#define AP_SOCACHE_PROVIDER_GROUP
#define AP_SOCACHE_PROVIDER_VERSION
#define STANDARD20_MODULE_STUFF
void ap_bin2hex(const void *src, apr_size_t srclen, char *dest)
#define AP_DEBUG_ASSERT(exp)
apr_status_t ap_timeout_parameter_parse(const char *timeout_parameter, apr_interval_time_t *timeout, const char *default_time_unit)
const char int apr_pool_t * pool
#define apr_pcalloc(p, size)
apr_int64_t apr_interval_time_t
#define apr_time_sec(time)
#define apr_time_from_sec(sec)
apr_status_t ap_mpm_query(int query_code, int *result)
#define AP_MPMQ_HARD_LIMIT_THREADS
static void socache_rd_status(ap_socache_instance_t *ctx, request_rec *r, int flags)
static void * create_server_config(apr_pool_t *p, server_rec *s)
static apr_status_t socache_rd_init(ap_socache_instance_t *ctx, const char *namespace, const struct ap_socache_hints *hints, server_rec *s, apr_pool_t *p)
static apr_status_t socache_rd_remove(ap_socache_instance_t *ctx, server_rec *s, const unsigned char *id, unsigned int idlen, apr_pool_t *p)
static int socache_rd_id2key(ap_socache_instance_t *ctx, const unsigned char *id, unsigned int idlen, char *key, apr_size_t keylen)
#define RD_DEFAULT_SERVER_SMAX
#define RD_DEFAULT_SERVER_TTL
static apr_status_t socache_rd_retrieve(ap_socache_instance_t *ctx, server_rec *s, const unsigned char *id, unsigned int idlen, unsigned char *dest, unsigned int *destlen, apr_pool_t *p)
#define RD_DEFAULT_SERVER_MIN
static const ap_socache_provider_t socache_mc
static void socache_rd_destroy(ap_socache_instance_t *context, server_rec *s)
static void register_hooks(apr_pool_t *p)
static const char * socache_rd_set_rwto(cmd_parms *cmd, void *dummy, const char *arg)
#define RD_DEFAULT_SERVER_RWTO
#define RD_DEFAULT_SERVER_PORT
static const command_rec socache_redis_cmds[]
static const char * socache_rd_set_ttl(cmd_parms *cmd, void *dummy, const char *arg)
static apr_status_t socache_rd_iterate(ap_socache_instance_t *instance, server_rec *s, void *userctx, ap_socache_iterator_t *iterator, apr_pool_t *pool)
static apr_status_t socache_rd_store(ap_socache_instance_t *ctx, server_rec *s, const unsigned char *id, unsigned int idlen, apr_time_t expiry, unsigned char *ucaData, unsigned int nData, apr_pool_t *p)
static const char * socache_rd_create(ap_socache_instance_t **context, const char *arg, apr_pool_t *tmp, apr_pool_t *p)
Status Report Extension Module to Apache.
apr_redis_server_status_t status
apr_redis_server_t ** live_servers
A structure that represents the current request.
A structure to store information for each virtual server.
static size_t keylen(KEY s)