Apache Portable Runtime Utility Library
apr_memcache.h
Go to the documentation of this file.
1/* Licensed to the Apache Software Foundation (ASF) under one or more
2 * contributor license agreements. See the NOTICE file distributed with
3 * this work for additional information regarding copyright ownership.
4 * The ASF licenses this file to You under the Apache License, Version 2.0
5 * (the "License"); you may not use this file except in compliance with
6 * the License. You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef APR_MEMCACHE_H
18#define APR_MEMCACHE_H
19
28#include "apr.h"
29#include "apr_pools.h"
30#include "apr_time.h"
31#include "apr_strings.h"
32#include "apr_network_io.h"
33#include "apr_ring.h"
34#include "apr_buckets.h"
35#include "apr_reslist.h"
36#include "apr_hash.h"
37
38#ifdef __cplusplus
39extern "C" {
40#endif /* __cplusplus */
41
49typedef enum
50{
54
57
61{
62 const char *host;
63 apr_port_t port;
65#if APR_HAS_THREADS || defined(DOXYGEN)
67#else
69#endif
70 apr_pool_t *p;
71#if APR_HAS_THREADS
72 apr_thread_mutex_t *lock;
73#endif
74 apr_time_t btime;
75};
76
77/* Custom hash callback function prototype, user for server selection.
78* @param baton user selected baton
79* @param data data to hash
80* @param data_len length of data
81*/
82typedef apr_uint32_t (*apr_memcache_hash_func)(void *baton,
83 const char *data,
84 const apr_size_t data_len);
85
86typedef struct apr_memcache_t apr_memcache_t;
87
88/* Custom Server Select callback function prototype.
89* @param baton user selected baton
90* @param mc memcache instance, use mc->live_servers to select a node
91* @param hash hash of the selected key.
92*/
93typedef apr_memcache_server_t* (*apr_memcache_server_func)(void *baton,
95 const apr_uint32_t hash);
96
99{
100 apr_uint32_t flags;
101 apr_uint16_t nalloc;
102 apr_uint16_t ntotal;
104 apr_pool_t *p;
106 apr_memcache_hash_func hash_func;
107 void *server_baton;
108 apr_memcache_server_func server_func;
109};
110
112typedef struct
113{
114 apr_status_t status;
115 const char* key;
116 apr_size_t len;
117 char *data;
118 apr_uint16_t flags;
120
129APU_DECLARE(apr_uint32_t) apr_memcache_hash(apr_memcache_t *mc,
130 const char *data,
131 const apr_size_t data_len);
132
136APU_DECLARE(apr_uint32_t) apr_memcache_hash_crc32(void *baton,
137 const char *data,
138 const apr_size_t data_len);
139
143APU_DECLARE(apr_uint32_t) apr_memcache_hash_default(void *baton,
144 const char *data,
145 const apr_size_t data_len);
146
155 const apr_uint32_t hash);
156
161 apr_memcache_t *mc,
162 const apr_uint32_t hash);
163
172APU_DECLARE(apr_status_t) apr_memcache_add_server(apr_memcache_t *mc,
173 apr_memcache_server_t *server);
174
175
184 const char *host,
185 apr_port_t port);
186
192APU_DECLARE(apr_status_t) apr_memcache_enable_server(apr_memcache_t *mc,
194
195
201APU_DECLARE(apr_status_t) apr_memcache_disable_server(apr_memcache_t *mc,
203
217APU_DECLARE(apr_status_t) apr_memcache_server_create(apr_pool_t *p,
218 const char *host,
219 apr_port_t port,
220 apr_uint32_t min,
221 apr_uint32_t smax,
222 apr_uint32_t max,
223 apr_uint32_t ttl,
232APU_DECLARE(apr_status_t) apr_memcache_create(apr_pool_t *p,
233 apr_uint16_t max_servers,
234 apr_uint32_t flags,
235 apr_memcache_t **mc);
236
247APU_DECLARE(apr_status_t) apr_memcache_getp(apr_memcache_t *mc,
248 apr_pool_t *p,
249 const char* key,
250 char **baton,
251 apr_size_t *len,
252 apr_uint16_t *flags);
253
254
263APU_DECLARE(void) apr_memcache_add_multget_key(apr_pool_t *data_pool,
264 const char* key,
265 apr_hash_t **values);
266
277APU_DECLARE(apr_status_t) apr_memcache_multgetp(apr_memcache_t *mc,
278 apr_pool_t *temp_pool,
279 apr_pool_t *data_pool,
280 apr_hash_t *values);
281
291APU_DECLARE(apr_status_t) apr_memcache_set(apr_memcache_t *mc,
292 const char *key,
293 char *baton,
294 const apr_size_t data_size,
295 apr_uint32_t timeout,
296 apr_uint16_t flags);
297
309APU_DECLARE(apr_status_t) apr_memcache_add(apr_memcache_t *mc,
310 const char *key,
311 char *baton,
312 const apr_size_t data_size,
313 apr_uint32_t timeout,
314 apr_uint16_t flags);
315
327APU_DECLARE(apr_status_t) apr_memcache_replace(apr_memcache_t *mc,
328 const char *key,
329 char *baton,
330 const apr_size_t data_size,
331 apr_uint32_t timeout,
332 apr_uint16_t flags);
339APU_DECLARE(apr_status_t) apr_memcache_delete(apr_memcache_t *mc,
340 const char *key,
341 apr_uint32_t timeout);
342
350APU_DECLARE(apr_status_t) apr_memcache_incr(apr_memcache_t *mc,
351 const char *key,
352 apr_int32_t n,
353 apr_uint32_t *nv);
354
362APU_DECLARE(apr_status_t) apr_memcache_decr(apr_memcache_t *mc,
363 const char *key,
364 apr_int32_t n,
365 apr_uint32_t *new_value);
366
374APU_DECLARE(apr_status_t) apr_memcache_version(apr_memcache_server_t *ms,
375 apr_pool_t *p,
376 char **baton);
377
378typedef struct
379{
381 const char *version;
383 apr_uint32_t pid;
385 apr_uint32_t uptime;
387 apr_time_t time;
389 apr_uint32_t pointer_size;
391 apr_time_t rusage_user;
393 apr_time_t rusage_system;
395 apr_uint32_t curr_items;
397 apr_uint32_t total_items;
399 apr_uint64_t bytes;
401 apr_uint32_t curr_connections;
403 apr_uint32_t total_connections;
407 apr_uint32_t cmd_get;
409 apr_uint32_t cmd_set;
411 apr_uint32_t get_hits;
413 apr_uint32_t get_misses;
416 apr_uint64_t evictions;
418 apr_uint64_t bytes_read;
420 apr_uint64_t bytes_written;
422 apr_uint32_t limit_maxbytes;
424 apr_uint32_t threads;
426
433APU_DECLARE(apr_status_t) apr_memcache_stats(apr_memcache_server_t *ms,
434 apr_pool_t *p,
435 apr_memcache_stats_t **stats);
436
437
440#ifdef __cplusplus
441}
442#endif
443
444#endif /* APR_MEMCACHE_H */
APR-UTIL Buckets/Bucket Brigades.
APR-UTIL Resource List Routines.
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_uint32_t apr_memcache_hash_crc32(void *baton, const char *data, const apr_size_t data_len)
apr_status_t apr_memcache_server_create(apr_pool_t *p, const char *host, apr_port_t port, apr_uint32_t min, apr_uint32_t smax, apr_uint32_t max, apr_uint32_t ttl, apr_memcache_server_t **ns)
apr_status_t apr_memcache_version(apr_memcache_server_t *ms, apr_pool_t *p, char **baton)
apr_status_t apr_memcache_incr(apr_memcache_t *mc, const char *key, apr_int32_t n, apr_uint32_t *nv)
apr_memcache_server_status_t
Definition: apr_memcache.h:50
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_multgetp(apr_memcache_t *mc, apr_pool_t *temp_pool, apr_pool_t *data_pool, apr_hash_t *values)
apr_memcache_server_t * apr_memcache_find_server(apr_memcache_t *mc, const char *host, apr_port_t port)
apr_status_t apr_memcache_create(apr_pool_t *p, apr_uint16_t max_servers, apr_uint32_t flags, apr_memcache_t **mc)
apr_memcache_server_t * apr_memcache_find_server_hash(apr_memcache_t *mc, const apr_uint32_t hash)
apr_uint32_t apr_memcache_hash_default(void *baton, const char *data, const apr_size_t data_len)
apr_uint32_t apr_memcache_hash(apr_memcache_t *mc, const char *data, const apr_size_t data_len)
apr_status_t apr_memcache_delete(apr_memcache_t *mc, const char *key, apr_uint32_t timeout)
apr_status_t apr_memcache_add_server(apr_memcache_t *mc, apr_memcache_server_t *server)
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_getp(apr_memcache_t *mc, apr_pool_t *p, const char *key, char **baton, apr_size_t *len, apr_uint16_t *flags)
struct apr_memcache_conn_t apr_memcache_conn_t
Definition: apr_memcache.h:56
void apr_memcache_add_multget_key(apr_pool_t *data_pool, const char *key, apr_hash_t **values)
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_stats(apr_memcache_server_t *ms, apr_pool_t *p, apr_memcache_stats_t **stats)
apr_status_t apr_memcache_disable_server(apr_memcache_t *mc, apr_memcache_server_t *ms)
apr_status_t apr_memcache_enable_server(apr_memcache_t *mc, apr_memcache_server_t *ms)
apr_memcache_server_t * apr_memcache_find_server_hash_default(void *baton, apr_memcache_t *mc, const apr_uint32_t hash)
@ APR_MC_SERVER_LIVE
Definition: apr_memcache.h:51
@ APR_MC_SERVER_DEAD
Definition: apr_memcache.h:52
struct apr_reslist_t apr_reslist_t
Definition: apr_reslist.h:42
Definition: apr_memcache.h:61
const char * host
Definition: apr_memcache.h:62
apr_reslist_t * conns
Definition: apr_memcache.h:66
apr_memcache_server_status_t status
Definition: apr_memcache.h:64
apr_thread_mutex_t * lock
Definition: apr_memcache.h:72
apr_port_t port
Definition: apr_memcache.h:63
Definition: apr_memcache.h:379
apr_uint32_t pointer_size
Definition: apr_memcache.h:389
apr_uint64_t bytes_written
Definition: apr_memcache.h:420
apr_uint32_t curr_connections
Definition: apr_memcache.h:401
apr_uint32_t total_items
Definition: apr_memcache.h:397
apr_time_t rusage_system
Definition: apr_memcache.h:393
apr_uint64_t bytes
Definition: apr_memcache.h:399
apr_uint32_t total_connections
Definition: apr_memcache.h:403
apr_uint32_t cmd_set
Definition: apr_memcache.h:409
apr_uint32_t threads
Definition: apr_memcache.h:424
apr_time_t rusage_user
Definition: apr_memcache.h:391
const char * version
Definition: apr_memcache.h:381
apr_uint32_t get_hits
Definition: apr_memcache.h:411
apr_uint32_t pid
Definition: apr_memcache.h:383
apr_uint32_t cmd_get
Definition: apr_memcache.h:407
apr_uint32_t curr_items
Definition: apr_memcache.h:395
apr_uint32_t connection_structures
Definition: apr_memcache.h:405
apr_uint64_t bytes_read
Definition: apr_memcache.h:418
apr_uint64_t evictions
Definition: apr_memcache.h:416
apr_time_t time
Definition: apr_memcache.h:387
apr_uint32_t uptime
Definition: apr_memcache.h:385
apr_uint32_t limit_maxbytes
Definition: apr_memcache.h:422
apr_uint32_t get_misses
Definition: apr_memcache.h:413
Definition: apr_memcache.h:99
void * hash_baton
Definition: apr_memcache.h:105
apr_memcache_server_t ** live_servers
Definition: apr_memcache.h:103
apr_uint16_t ntotal
Definition: apr_memcache.h:102
apr_uint16_t nalloc
Definition: apr_memcache.h:101
apr_uint32_t flags
Definition: apr_memcache.h:100
Definition: apr_memcache.h:113