upload http
[bottlenecks.git] / rubbos / app / httpd-2.0.64 / modules / experimental / cache_cache.h
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 CACHE_CACHE_H
18 #define CACHE_CACHE_H
19
20 #ifdef __cplusplus
21 extern "C" {
22 #endif
23
24 #include "mod_cache.h"
25
26 /**
27  * @file cache_hash.h
28  * @brief Cache Cache Functions
29  */
30
31 /**
32  * @defgroup Cache_cache  Cache Functions
33  * @ingroup CACHE
34  * @{
35  */
36 /** ADT for the cache */
37 typedef struct cache_cache_t cache_cache_t;
38
39 /** callback to increment the frequency of a item */
40 typedef void cache_cache_inc_frequency(void*a);
41 /** callback to get the size of a item */
42 typedef apr_size_t cache_cache_get_size(void*a);
43 /** callback to get the key of a item */
44 typedef const char* cache_cache_get_key(void *a);
45 /** callback to free an entry */
46 typedef void cache_cache_free(void *a);
47
48 /**
49  * initialize the cache ADT
50  * @param max_entries the number of entries in the cache
51  * @param max_size    the size of the cache
52  * @param get_pri     callback to get a priority of a entry
53  * @param set_pri     callback to set a priority of a entry
54  * @param get_pos     callback to get the position of a entry in the cache
55  * @param set_pos     callback to set the position of a entry in the cache
56  * @param inc_entry   callback to increment the frequency of a entry
57  * @param size_entry  callback to get the size of a entry
58  * @param key_entry   callback to get the key of a entry
59  * @param free_entry  callback to free an entry
60  */
61 CACHE_DECLARE(cache_cache_t *)cache_init(int max_entries, 
62                                          apr_size_t max_size,
63                                          cache_pqueue_get_priority get_pri,
64                                          cache_pqueue_set_priority set_pri,
65                                          cache_pqueue_getpos get_pos,
66                                          cache_pqueue_setpos set_pos,
67                                          cache_cache_inc_frequency *inc_entry,
68                                          cache_cache_get_size *size_entry,
69                                          cache_cache_get_key *key_entry,
70                                          cache_cache_free *free_entry);
71
72 /**
73  * free up the cache
74  * @param c the cache
75  */
76 CACHE_DECLARE(void) cache_free(cache_cache_t *c);
77 /**
78  * find a entry in the cache, incrementing the frequency if found
79  * @param c the cache
80  * @param key the key
81  */
82 CACHE_DECLARE(void*) cache_find(cache_cache_t* c, const char *key);
83 /** 
84  * insert a entry into the cache
85  * @param c the cache
86  * @param entry the entry
87  */
88 CACHE_DECLARE(void) cache_update(cache_cache_t* c, void *entry);
89 /** 
90  * insert a entry into the cache
91  * @param c the cache
92  * @param entry the entry
93  */
94 CACHE_DECLARE(void) cache_insert(cache_cache_t* c, void *entry);
95 /**
96  * pop the lowest priority item off
97  * @param c the cache
98  * @returns the entry or NULL
99  */
100 CACHE_DECLARE(void *)cache_pop(cache_cache_t* c);
101 /** 
102  * remove an item from the cache 
103  * @param c the cache
104  * @param entry the actual entry (from a find)
105  */
106 CACHE_DECLARE(apr_status_t) cache_remove(cache_cache_t* c, void *entry);
107 /** @} */
108 #ifdef __cplusplus
109 }
110 #endif
111
112 #endif /* !CACHE_CACHE_H */