NAME

cat_newmemdb - create a new, in-memory, cache database.

SYNOPSIS

#include <cat/cat.h>

#include <cat/catutil.h>

int cat_newmemdb(int nbuckets, int ttl, cat_memdb **db);

DESCRIPTION

This function creates a new, in-memory, database. The nbuckets argument should be set to the approximate expected number of concurrent entries in the database. If nbuckets is less than or equal to zero, a built-in default value will be used.

The ttl value specifies the time-to-live, in seconds, for entries in the database. Entries older than this will be purged from the database. A ttl of zero disables expiration of entries, while a negative one causes a built-in default value to be used.

If the function is successful, the db value will point to the initialized database.

The database should be freed by the caller with a call to cat_freememdb.

NOTES

This function is suitbale for use with the catssl_setdb, catdasp_setdb or catcert_setdb functions. In this case, the db value is suitable as the handle in parameter to the setdb functions.

This function is not thread-safe. The sequence of database accesses must be handled by the caller.

RETURN VALUES

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

SEE ALSO

cat, catutil

cat_freememdb, cat_memdbfunc, cat_memdbforeach, cat_memdbflags, catssl_setdb, catdasp_setdb, catcert_setdb