<!--$Id: ram.so,v 10.6 2004/09/28 13:31:25 bostic Exp $--> <!--Copyright 1997-2004 by Sleepycat Software, Inc.--> <!--All rights reserved.--> <!--See the file LICENSE for redistribution information.--> <html> <head> <title>Berkeley DB Reference Guide: Memory-only configurations</title> <meta name="description" content="Berkeley DB: An embedded database programmatic toolkit."> <meta name="keywords" content="embedded,database,programmatic,toolkit,btree,hash,hashing,transaction,transactions,locking,logging,access method,access methods,Java,C,C++"> </head> <body bgcolor=white> <table width="100%"><tr valign=top> <td><h3><dl><dt>Berkeley DB Reference Guide:<dd>Programmer Notes</dl></h3></td> <td align=right><a href="../program/namespace.html"><img src="../../images/prev.gif" alt="Prev"></a><a href="../toc.html"><img src="../../images/ref.gif" alt="Ref"></a><a href="../program/cache.html"><img src="../../images/next.gif" alt="Next"></a> </td></tr></table> <p> <h3 align=center>Memory-only configurations</h3> <p>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.</p> <p>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 <a href="../../api_c/env_open.html#DB_PRIVATE">DB_PRIVATE</a> flag to the <a href="../../api_c/env_open.html">DB_ENV->open</a> 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 <a href="../../api_c/env_open.html#DB_SYSTEM_MEM">DB_SYSTEM_MEM</a> flag to the <a href="../../api_c/env_open.html">DB_ENV->open</a> 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.</p> <p>Second, database files. Applications can create RAM-only databases by not specifying a physical filename when opening the database using the <a href="../../api_c/db_open.html">DB->open</a> method. Normally, if the database environment cache fills up Berkeley DB will create temporary backing files for RAM-only databases. Use the <a href="../../api_c/memp_set_flags.html#DB_MPOOL_NOFILE">DB_MPOOL_NOFILE</a> flag to the <a href="../../api_c/memp_set_flags.html">DB_MPOOLFILE->set_flags</a> method to configure the cache to never create backing files for a database. Use the <a href="../../api_c/memp_set_maxsize.html">DB_MPOOLFILE->set_maxsize</a> method to limit the size of a database so it cannot dirty the entire cache.</p> <p>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 <a href="../../api_c/env_set_flags.html#DB_LOG_INMEMORY">DB_LOG_INMEMORY</a> flag to the <a href="../../api_c/env_set_flags.html">DB_ENV->set_flags</a> method. To configure an individual database in a database environment to be transactional but not durable, specify the <a href="../../api_c/db_set_flags.html#DB_TXN_NOT_DURABLE">DB_TXN_NOT_DURABLE</a> flag to the <a href="../../api_c/db_set_flags.html">DB->set_flags</a> method.</p> <table width="100%"><tr><td><br></td><td align=right><a href="../program/namespace.html"><img src="../../images/prev.gif" alt="Prev"></a><a href="../toc.html"><img src="../../images/ref.gif" alt="Ref"></a><a href="../program/cache.html"><img src="../../images/next.gif" alt="Next"></a> </td></tr></table> <p><font size=1><a href="../../sleepycat/legal.html">Copyright (c) 1996-2004</a> <a href="http://www.sleepycat.com">Sleepycat Software, Inc.</a> - All rights reserved.</font> </body> </html>