<ahref="ext.html#ext_mod">Using Berkeley DB with Apache</a>
</span>
</dt>
<dt>
<spanclass="sect1">
<ahref="ext_perl.html">Using Berkeley DB with Perl</a>
</span>
</dt>
<dt>
<spanclass="sect1">
<ahref="ext_php.html">Using Berkeley DB with PHP</a>
</span>
</dt>
</dl>
</div>
<divclass="sect1"lang="en"xml:lang="en">
<divclass="titlepage">
<div>
<div>
<h2class="title"style="clear: both"><aid="ext_mod"></a>Using Berkeley DB with Apache</h2>
</div>
</div>
</div>
<p>A mod_db4 Apache module is included in the Berkeley DB distribution, providing
a safe framework for running Berkeley DB applications in an Apache 1.3
environment. Apache natively provides no interface for communication
between threads or processes, so the mod_db4 module exists to provide
this communication.</p>
<p>In general, it is dangerous to run Berkeley DB in a multiprocess system
without some facility to coordinate database recovery between processes
sharing the database environment after application or system failure.
Failure to run recovery after failure can include process hangs and an
inability to access the database environment. The mod_db4 Apache module
oversees the proper management of Berkeley DB database environment resources.
Developers building applications using Berkeley DB as the storage manager
within an Apache module should employ this technique for proper resource
management.</p>
<p>Specifically, mod_db4 provides the following facilities:</p>
<divclass="orderedlist">
<oltype="1">
<li>New constructors for <ahref="../api_reference/C/env.html"class="olink">DB_ENV</a> and <ahref="../api_reference/C/db.html"class="olink">DB</a> handles, which install
replacement open/close methods.</li>
<li>Transparent caching of open <ahref="../api_reference/C/env.html"class="olink">DB_ENV</a> and <ahref="../api_reference/C/db.html"class="olink">DB</a> handles.</li>
<li>Reference counting on all structures, allowing the module to detect the
initial opening of any managed database and automatically perform recovery.</li>
<li>Automatic detection of unexpected failures (segfaults, or a module
actually calling exit() and avoiding shut down phases), and automatic
termination of all child processes with open database resources to
attempt consistency.</li>
</ol>
</div>
<p>mod_db4 is designed to be used as an alternative interface to Berkeley DB. To
have another Apache module (for example, mod_foo) use mod_db4, do not
link mod_foo against the Berkeley DB library. In your mod_foo makefile, you