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