NAME

cat_newfiledb - create a new cache file

SYNOPSIS

#include <cat/cat.h>

#include <cat/catutil.h>

int cat_newfiledb(const char *filename, int entries, int ttl, cat_filedb **db);

DESCRIPTION

This function opens or creates the on disk database file filename. The entries argument indicates how many entries the database is expected to contain, although the file will grow larger if necessary. If the default value for entries is to be used, use 0.

The ttl argument is the time-to-live, in seconds, for each entry. Entries older than this will be purged from the database. A negative or zero ttl will cause a built-in default value to be used.

If several processes open the database, where each process specifies different values for ttl and/or entries, the value that gets selected is undefined.

If the function is successful, the db will refer to the on-disk database. The db must be closed by the caller with a call to cat_freefiledb().

NOTES

The filedb is currently available only on UNIX

The filedb functions are not thread-safe. It is up to the caller to ensure that all accesses are handled in the correct sequence.

Only one instance of a file database for a single file can exist in the same process.

RETURN VALUES

The function returns 0 if successful, and a negative code on error.

SEE ALSO

catutil, cat_filedbfunc, cat_freefiledb