cache.h revision 40f53fa8d9c6a4fc38c0014495e7a42b08f52481
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNico * Copyright (C) 1999, 2000 Internet Software Consortium.
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNico * Permission to use, copy, modify, and distribute this software for any
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNico * purpose with or without fee is hereby granted, provided that the above
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNico * copyright notice and this permission notice appear in all copies.
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNico * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNico * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNico * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNico * INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT,
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNico * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNico * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNico * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNico * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNico/* $Id: cache.h,v 1.13 2000/08/01 01:23:43 tale Exp $ */
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNico ***** Module Info
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNico * Defines dns_cache_t, the cache object.
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNico * A cache object contains DNS data of a single class.
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNico * Multiple classes will be handled by creating multiple
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNico * views, each with a different class and its own cache.
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNico * See notes at the individual functions.
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNico * Reliability:
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNico * Resources:
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNico * Standards:
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNico *** Functions
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNicodns_cache_create(isc_mem_t *mctx, isc_taskmgr_t *taskmgr,
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNico isc_timermgr_t *timermgr, dns_rdataclass_t rdclass,
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNico const char *db_type, unsigned int db_argc, char **db_argv,
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNico * Create a new DNS cache.
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNico * 'mctx' is a valid memory context
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNico * 'taskmgr' is a valid task manager and 'timermgr' is a valid timer
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNico * manager, or both are NULL. If NULL, no periodic cleaning of the
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNico * cache will take place.
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNico * 'cachep' is a valid pointer, and *cachep == NULL
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNico * '*cachep' is attached to the newly created cache
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNico * ISC_R_SUCCESS
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNico * ISC_R_NOMEMORY
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNicodns_cache_attach(dns_cache_t *cache, dns_cache_t **targetp);
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNico * Attach *targetp to cache.
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNico * 'cache' is a valid cache.
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNico * 'targetp' points to a NULL dns_cache_t *.
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNico * *targetp is attached to cache.
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNico * Detach *cachep from its cache.
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNico * 'cachep' points to a valid cache.
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNico * *cachep is NULL.
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNico * If '*cachep' is the last reference to the cache,
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNico * All resources used by the cache will be freed
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNicodns_cache_attachdb(dns_cache_t *cache, dns_db_t **dbp);
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNico * Attach *dbp to the cache's database.
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNico * This may be used to get a reference to the database for
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNico * the purpose of cache lookups (XXX currently it is also
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNico * the way to add data to the cache, but having a
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNico * separate dns_cache_add() interface instead would allow
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNico * more control over memory usage).
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNico * The caller should call dns_db_detach() on the reference
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNico * when it is no longer needed.
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNico * 'cache' is a valid cache.
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNico * 'dbp' points to a NULL dns_db *.
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNico * *dbp is attached to the database.
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNicodns_cache_setfilename(dns_cache_t *cahce, char *filename);
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNico * If 'filename' is non-NULL, make the cache persistent.
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNico * The cache's data will be stored in the given file.
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNico * If 'filename' is NULL, make the cache non-persistent.
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNico * Files that are no longer used are not unlinked automatically.
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNico * ISC_R_SUCCESS
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNico * ISC_R_NOMEMORY
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNico * Various file-related failures
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNico * If the cache has a file name, load the cache contents from the file.
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNico * Previous cache contents are not discarded.
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNico * If no file name has been set, do nothing and return success.
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNico * Multiple simultaneous attempts to load or dump the cache
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNico * will be serialized with respect to one another, but
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNico * the cache may be read and updated while the dump is
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNico * in progress. Updates performed during loading
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNico * may or may not be preserved, and reads may return
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNico * either the old or the newly loaded data.
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNico * ISC_R_SUCCESS
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNico * Various failures depending on the database implementation type
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNico * If the cache has a file name, write the cache contents to disk,
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNico * overwriting any preexisting file. If no file name has been set,
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNico * do nothing and return success.
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNico * Multiple simultaneous attempts to load or dump the cache
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNico * will be serialized with respect to one another, but
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNico * the cache may be read and updated while the dump is
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNico * in progress. Updates performed during the dump may
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNico * or may not be reflected in the dumped file.
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNico * ISC_R_SUCCESS
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNico * Various failures depending on the database implementation type
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNicodns_cache_clean(dns_cache_t *cache, isc_stdtime_t now);
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNico * Force immediate cleaning of the cache, freeing all rdatasets
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNico * whose TTL has expired as of 'now' and that have no pending
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNico * references.
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNicodns_cache_setcleaninginterval(dns_cache_t *cache, unsigned int interval);
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNico * Set the periodic cache cleaning interval to 'interval' seconds.
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNico#endif /* DNS_CACHE_H */