Apache2
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_buckets.h"
34 #include "apr_ring.h"
35 #include "apr_reslist.h"
36 #include "apr_hash.h"
37 
38 #ifdef __cplusplus
39 extern "C" {
40 #endif /* __cplusplus */
41 
49 typedef enum
50 {
54 
57 
61 {
62  const char *host;
65 #if APR_HAS_THREADS || defined(DOXYGEN)
67 #else
68  apr_memcache_conn_t *conn;
69 #endif
71 #if APR_HAS_THREADS
73 #endif
75 #if APR_HAS_THREADS
77  int min;
78  int smax;
79  int max;
81 #endif
82 };
83 
84 /* Custom hash callback function prototype, user for server selection.
85 * @param baton user selected baton
86 * @param data data to hash
87 * @param data_len length of data
88 */
89 typedef apr_uint32_t (*apr_memcache_hash_func)(void *baton,
90  const char *data,
91  const apr_size_t data_len);
92 
93 typedef struct apr_memcache_t apr_memcache_t;
94 
95 /* Custom Server Select callback function prototype.
96 * @param baton user selected baton
97 * @param mc memcache instance, use mc->live_servers to select a node
98 * @param hash hash of the selected key.
99 */
100 typedef apr_memcache_server_t* (*apr_memcache_server_func)(void *baton,
101  apr_memcache_t *mc,
102  const apr_uint32_t hash);
103 
106 {
112  void *hash_baton;
118 };
119 
121 typedef struct
122 {
124  const char* key;
126  char *data;
129 
139  const char *data,
140  const apr_size_t data_len);
141 
146  const char *data,
147  const apr_size_t data_len);
148 
153  const char *data,
154  const apr_size_t data_len);
155 
164  const apr_uint32_t hash);
165 
171  apr_memcache_t *mc,
172  const apr_uint32_t hash);
173 
183  apr_memcache_server_t *server);
184 
185 
194  const char *host,
195  apr_port_t port);
196 
204 
205 
213 
214 
222  apr_time_t retry_period);
223 
224 
232 
233 
248  const char *host,
249  apr_port_t port,
250  int min,
251  int smax,
252  int max,
263  apr_uint16_t max_servers,
265  apr_memcache_t **mc);
266 
278  apr_pool_t *p,
279  const char* key,
280  char **baton,
281  apr_size_t *len,
283 
284 
294  const char* key,
295  apr_hash_t **values);
296 
308  apr_pool_t *temp_pool,
309  apr_pool_t *data_pool,
310  apr_hash_t *values);
311 
322  const char *key,
323  char *baton,
324  const apr_size_t data_size,
325  apr_uint32_t timeout,
327 
340  const char *key,
341  char *baton,
342  const apr_size_t data_size,
343  apr_uint32_t timeout,
345 
358  const char *key,
359  char *baton,
360  const apr_size_t data_size,
361  apr_uint32_t timeout,
370  const char *key,
371  apr_uint32_t timeout);
372 
381  const char *key,
382  apr_int32_t n,
383  apr_uint32_t *nv);
384 
393  const char *key,
394  apr_int32_t n,
395  apr_uint32_t *new_value);
396 
404  apr_pool_t *p,
405  char **baton);
406 
407 typedef struct
408 {
410  const char *version;
455 
463  apr_pool_t *p,
464  apr_memcache_stats_t **stats);
465 
466 
469 #ifdef __cplusplus
470 }
471 #endif
472 
473 #endif /* APR_MEMCACHE_H */
APR Platform Definitions.
APR-UTIL Buckets/Bucket Brigades.
APR Hash Tables.
APR Network library.
APR memory allocation.
APR-UTIL Resource List Routines.
APR Rings.
APR Strings library.
APR Time Library.
apr_memcache_server_t * apr_memcache_find_server_hash_default(void *baton, apr_memcache_t *mc, const apr_uint32_t hash)
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_version(apr_memcache_server_t *ms, apr_pool_t *p, char **baton)
void apr_memcache_set_retry_period(apr_memcache_t *mc, apr_time_t retry_period)
apr_memcache_server_t * apr_memcache_find_server_hash(apr_memcache_t *mc, const apr_uint32_t hash)
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_memcache_server_t *(* apr_memcache_server_func)(void *baton, apr_memcache_t *mc, const apr_uint32_t hash)
Definition: apr_memcache.h:100
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_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_uint32_t(* apr_memcache_hash_func)(void *baton, const char *data, const apr_size_t data_len)
Definition: apr_memcache.h:89
apr_uint32_t apr_memcache_hash_default(void *baton, const char *data, const apr_size_t data_len)
apr_memcache_server_t * apr_memcache_find_server(apr_memcache_t *mc, const char *host, apr_port_t port)
apr_time_t apr_memcache_get_retry_period(apr_memcache_t *mc)
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_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
dav_resource int dav_locktoken dav_response int flags
Definition: mod_dav.h:1458
int ns
Definition: mod_dav.h:587
int apr_status_t
Definition: apr_errno.h:44
struct apr_hash_t apr_hash_t
Definition: apr_hash.h:52
apr_uint16_t apr_port_t
Definition: apr_network_io.h:230
int apr_int32_t
Definition: apr.h:347
unsigned short apr_uint16_t
Definition: apr.h:345
unsigned int apr_uint32_t
Definition: apr.h:348
size_t apr_size_t
Definition: apr.h:394
uint64_t apr_uint64_t
Definition: apr.h:387
struct apr_pool_t apr_pool_t
Definition: apr_pools.h:60
apr_int64_t apr_interval_time_t
Definition: apr_time.h:55
apr_int64_t apr_time_t
Definition: apr_time.h:45
#define APR_DECLARE(x)
Definition: macros.h:6
Definition: apr_memcache.h:61
int max
Definition: apr_memcache.h:79
apr_pool_t * p
Definition: apr_memcache.h:70
int smax
Definition: apr_memcache.h:78
const char * host
Definition: apr_memcache.h:62
apr_reslist_t * conns
Definition: apr_memcache.h:66
apr_time_t btime
Definition: apr_memcache.h:74
apr_memcache_server_status_t status
Definition: apr_memcache.h:64
int min
Definition: apr_memcache.h:77
apr_thread_mutex_t * lock
Definition: apr_memcache.h:72
apr_port_t port
Definition: apr_memcache.h:63
apr_interval_time_t ttl
Definition: apr_memcache.h:80
Definition: apr_memcache.h:408
apr_uint32_t pointer_size
Definition: apr_memcache.h:418
apr_uint64_t bytes_written
Definition: apr_memcache.h:449
apr_uint32_t curr_connections
Definition: apr_memcache.h:430
apr_uint32_t total_items
Definition: apr_memcache.h:426
apr_time_t rusage_system
Definition: apr_memcache.h:422
apr_uint64_t bytes
Definition: apr_memcache.h:428
apr_uint32_t total_connections
Definition: apr_memcache.h:432
apr_uint32_t cmd_set
Definition: apr_memcache.h:438
apr_uint32_t threads
Definition: apr_memcache.h:453
apr_time_t rusage_user
Definition: apr_memcache.h:420
const char * version
Definition: apr_memcache.h:410
apr_uint32_t get_hits
Definition: apr_memcache.h:440
apr_uint32_t pid
Definition: apr_memcache.h:412
apr_uint32_t cmd_get
Definition: apr_memcache.h:436
apr_uint32_t curr_items
Definition: apr_memcache.h:424
apr_uint32_t connection_structures
Definition: apr_memcache.h:434
apr_uint64_t bytes_read
Definition: apr_memcache.h:447
apr_uint64_t evictions
Definition: apr_memcache.h:445
apr_time_t time
Definition: apr_memcache.h:416
apr_uint32_t uptime
Definition: apr_memcache.h:414
apr_uint32_t limit_maxbytes
Definition: apr_memcache.h:451
apr_uint32_t get_misses
Definition: apr_memcache.h:442
Definition: apr_memcache.h:106
apr_memcache_server_func server_func
Definition: apr_memcache.h:115
void * hash_baton
Definition: apr_memcache.h:112
apr_pool_t * p
Definition: apr_memcache.h:111
apr_time_t retry_period
Definition: apr_memcache.h:117
apr_memcache_server_t ** live_servers
Definition: apr_memcache.h:110
apr_uint16_t ntotal
Definition: apr_memcache.h:109
apr_uint16_t nalloc
Definition: apr_memcache.h:108
apr_memcache_hash_func hash_func
Definition: apr_memcache.h:113
void * server_baton
Definition: apr_memcache.h:114
apr_uint32_t flags
Definition: apr_memcache.h:107
Definition: apr_memcache.h:122
apr_status_t status
Definition: apr_memcache.h:123
const char * key
Definition: apr_memcache.h:124
apr_uint16_t flags
Definition: apr_memcache.h:127
apr_size_t len
Definition: apr_memcache.h:125
char * data
Definition: apr_memcache.h:126
Definition: apr_arch_thread_mutex.h:28
apr_pool_t * p