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