2 * Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC")
3 * Copyright (C) 1999-2001 Internet Software Consortium.
5 * Permission to use, copy, modify, and distribute this software for any
6 * purpose with or without fee is hereby granted, provided that the above
7 * copyright notice and this permission notice appear in all copies.
9 * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
10 * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
11 * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
12 * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
13 * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
14 * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
15 * PERFORMANCE OF THIS SOFTWARE.
18 /* $Id: cache.h,v 1.17.2.1 2004/03/09 06:11:13 marka Exp $ */
30 * Defines dns_cache_t, the cache object.
33 * A cache object contains DNS data of a single class.
34 * Multiple classes will be handled by creating multiple
35 * views, each with a different class and its own cache.
38 * See notes at the individual functions.
54 #include <isc/stdtime.h>
56 #include <dns/types.h>
65 dns_cache_create(isc_mem_t *mctx, isc_taskmgr_t *taskmgr,
66 isc_timermgr_t *timermgr, dns_rdataclass_t rdclass,
67 const char *db_type, unsigned int db_argc, char **db_argv,
68 dns_cache_t **cachep);
70 * Create a new DNS cache.
74 * 'mctx' is a valid memory context
76 * 'taskmgr' is a valid task manager and 'timermgr' is a valid timer
77 * manager, or both are NULL. If NULL, no periodic cleaning of the
78 * cache will take place.
80 * 'cachep' is a valid pointer, and *cachep == NULL
84 * '*cachep' is attached to the newly created cache
93 dns_cache_attach(dns_cache_t *cache, dns_cache_t **targetp);
95 * Attach *targetp to cache.
99 * 'cache' is a valid cache.
101 * 'targetp' points to a NULL dns_cache_t *.
105 * *targetp is attached to cache.
109 dns_cache_detach(dns_cache_t **cachep);
111 * Detach *cachep from its cache.
115 * 'cachep' points to a valid cache.
121 * If '*cachep' is the last reference to the cache,
123 * All resources used by the cache will be freed
127 dns_cache_attachdb(dns_cache_t *cache, dns_db_t **dbp);
129 * Attach *dbp to the cache's database.
133 * This may be used to get a reference to the database for
134 * the purpose of cache lookups (XXX currently it is also
135 * the way to add data to the cache, but having a
136 * separate dns_cache_add() interface instead would allow
137 * more control over memory usage).
138 * The caller should call dns_db_detach() on the reference
139 * when it is no longer needed.
143 * 'cache' is a valid cache.
145 * 'dbp' points to a NULL dns_db *.
149 * *dbp is attached to the database.
154 dns_cache_setfilename(dns_cache_t *cahce, char *filename);
156 * If 'filename' is non-NULL, make the cache persistent.
157 * The cache's data will be stored in the given file.
158 * If 'filename' is NULL, make the cache non-persistent.
159 * Files that are no longer used are not unlinked automatically.
164 * Various file-related failures
168 dns_cache_load(dns_cache_t *cache);
170 * If the cache has a file name, load the cache contents from the file.
171 * Previous cache contents are not discarded.
172 * If no file name has been set, do nothing and return success.
175 * Multiple simultaneous attempts to load or dump the cache
176 * will be serialized with respect to one another, but
177 * the cache may be read and updated while the dump is
178 * in progress. Updates performed during loading
179 * may or may not be preserved, and reads may return
180 * either the old or the newly loaded data.
185 * Various failures depending on the database implementation type
189 dns_cache_dump(dns_cache_t *cache);
191 * If the cache has a file name, write the cache contents to disk,
192 * overwriting any preexisting file. If no file name has been set,
193 * do nothing and return success.
196 * Multiple simultaneous attempts to load or dump the cache
197 * will be serialized with respect to one another, but
198 * the cache may be read and updated while the dump is
199 * in progress. Updates performed during the dump may
200 * or may not be reflected in the dumped file.
205 * Various failures depending on the database implementation type
209 dns_cache_clean(dns_cache_t *cache, isc_stdtime_t now);
211 * Force immediate cleaning of the cache, freeing all rdatasets
212 * whose TTL has expired as of 'now' and that have no pending
217 dns_cache_setcleaninginterval(dns_cache_t *cache, unsigned int interval);
219 * Set the periodic cache cleaning interval to 'interval' seconds.
223 dns_cache_setcachesize(dns_cache_t *cache, isc_uint32_t size);
225 * Set the maximum cache size. 0 means unlimited.
229 dns_cache_flush(dns_cache_t *cache);
231 * Flushes all data from the cache.
240 #endif /* DNS_CACHE_H */