DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 

Berkeley DB Reference Guide:
Programmer Notes

PrevRefNext

Memory-only configurations

Berkeley DB supports a variety of memory-only configurations, intended for systems where filesystem space is limited in availability or entirely replaced by some combination of RAM and Flash. There are three database environment files that are potentially written to disk: database environment shared region files, database files and log files. Each of these file types can be individually configured to be created in memory rather than on disk.

First, database environment shared region files. Applications can create RAM-only database environments in two different types of memory: in application heap memory or in system shared memory. To create the database environment in heap memory, specify the DB_PRIVATE flag to the DB_ENV->open method. Database environments created in heap memory are only accessible to the threads of a single process, however. To create the database environment in system shared memory, specify the DB_SYSTEM_MEM flag to the DB_ENV->open method. Database environments created in system memory are accessible to multiple processes. However, database environments created in system shared memory do create a small (roughly 8 byte) file in the file system read by the processes to identify the system shared memory segments to use.

Second, database files. Applications can create RAM-only databases by not specifying a physical filename when opening the database using the DB->open method. Normally, if the database environment cache fills up Berkeley DB will create temporary backing files for RAM-only databases. Use the DB_MPOOL_NOFILE flag to the DB_MPOOLFILE->set_flags method to configure the cache to never create backing files for a database. Use the DB_MPOOLFILE->set_maxsize method to limit the size of a database so it cannot dirty the entire cache.

Third, log files. If a database environment is intended to be transactionally recoverable after application or system failure (that is, if it will exhibit the transactional attribute of "durability"), the databases and the database environment log files must either be written to the local disk and recovered, or they must be replicated to other systems. When durability is not desired, or is accomplished through replication, local database environments can be configured for transactional behavior without durability, resulting in log files never being written to disk. To configure a database environment this way, specify the DB_LOG_INMEMORY flag to the DB_ENV->set_flags method. To configure an individual database in a database environment to be transactional but not durable, specify the DB_TXN_NOT_DURABLE flag to the DB->set_flags method.


PrevRefNext

Copyright (c) 1996-2005 Sleepycat Software, Inc. - All rights reserved.