2 * Copyright (C) 2004, 2005 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.19.18.3 2005/08/23 02:31:38 marka Exp $ */
29 * Defines dns_cache_t, the cache object.
32 *\li A cache object contains DNS data of a single class.
33 * Multiple classes will be handled by creating multiple
34 * views, each with a different class and its own cache.
37 *\li See notes at the individual functions.
53 #include <isc/stdtime.h>
55 #include <dns/types.h>
64 dns_cache_create(isc_mem_t *mctx, isc_taskmgr_t *taskmgr,
65 isc_timermgr_t *timermgr, dns_rdataclass_t rdclass,
66 const char *db_type, unsigned int db_argc, char **db_argv,
67 dns_cache_t **cachep);
69 * Create a new DNS cache.
73 *\li 'mctx' is a valid memory context
75 *\li 'taskmgr' is a valid task manager and 'timermgr' is a valid timer
76 * manager, or both are NULL. If NULL, no periodic cleaning of the
77 * cache will take place.
79 *\li 'cachep' is a valid pointer, and *cachep == NULL
83 *\li '*cachep' is attached to the newly created cache
92 dns_cache_attach(dns_cache_t *cache, dns_cache_t **targetp);
94 * Attach *targetp to cache.
98 *\li 'cache' is a valid cache.
100 *\li 'targetp' points to a NULL dns_cache_t *.
104 *\li *targetp is attached to cache.
108 dns_cache_detach(dns_cache_t **cachep);
110 * Detach *cachep from its cache.
114 *\li 'cachep' points to a valid cache.
118 *\li *cachep is NULL.
120 *\li If '*cachep' is the last reference to the cache,
121 * all resources used by the cache will be freed
125 dns_cache_attachdb(dns_cache_t *cache, dns_db_t **dbp);
127 * Attach *dbp to the cache's database.
131 *\li This may be used to get a reference to the database for
132 * the purpose of cache lookups (XXX currently it is also
133 * the way to add data to the cache, but having a
134 * separate dns_cache_add() interface instead would allow
135 * more control over memory usage).
136 * The caller should call dns_db_detach() on the reference
137 * when it is no longer needed.
141 *\li 'cache' is a valid cache.
143 *\li 'dbp' points to a NULL dns_db *.
147 *\li *dbp is attached to the database.
152 dns_cache_setfilename(dns_cache_t *cache, const char *filename);
154 * If 'filename' is non-NULL, make the cache persistent.
155 * The cache's data will be stored in the given file.
156 * If 'filename' is NULL, make the cache non-persistent.
157 * Files that are no longer used are not unlinked automatically.
162 *\li Various file-related failures
166 dns_cache_load(dns_cache_t *cache);
168 * If the cache has a file name, load the cache contents from the file.
169 * Previous cache contents are not discarded.
170 * If no file name has been set, do nothing and return success.
173 *\li Multiple simultaneous attempts to load or dump the cache
174 * will be serialized with respect to one another, but
175 * the cache may be read and updated while the dump is
176 * in progress. Updates performed during loading
177 * may or may not be preserved, and reads may return
178 * either the old or the newly loaded data.
183 * \li Various failures depending on the database implementation type
187 dns_cache_dump(dns_cache_t *cache);
189 * If the cache has a file name, write the cache contents to disk,
190 * overwriting any preexisting file. If no file name has been set,
191 * do nothing and return success.
194 *\li Multiple simultaneous attempts to load or dump the cache
195 * will be serialized with respect to one another, but
196 * the cache may be read and updated while the dump is
197 * in progress. Updates performed during the dump may
198 * or may not be reflected in the dumped file.
203 * \li Various failures depending on the database implementation type
207 dns_cache_clean(dns_cache_t *cache, isc_stdtime_t now);
209 * Force immediate cleaning of the cache, freeing all rdatasets
210 * whose TTL has expired as of 'now' and that have no pending
215 dns_cache_setcleaninginterval(dns_cache_t *cache, unsigned int interval);
217 * Set the periodic cache cleaning interval to 'interval' seconds.
221 dns_cache_setcachesize(dns_cache_t *cache, isc_uint32_t size);
223 * Set the maximum cache size. 0 means unlimited.
227 dns_cache_flush(dns_cache_t *cache);
229 * Flushes all data from the cache.
237 dns_cache_flushname(dns_cache_t *cache, dns_name_t *name);
239 * Flushes a given name from the cache.
242 *\li 'cache' to be valid.
243 *\li 'name' to be valid.
248 *\li other error returns.
253 #endif /* DNS_CACHE_H */