# $OpenLDAP$
# Example DB_CONFIG file for use with slapd(8) BDB/HDB databases.
#
# See the Oracle Berkeley DB documentation
#   <http://www.oracle.com/technology/documentation/berkeley-db/db/ref/env/db_config.html>
# for detail description of DB_CONFIG syntax and semantics.
#
# Hints can also be found in the OpenLDAP Software FAQ
#       <http://www.openldap.org/faq/index.cgi?file=2>
# in particular:
#   <http://www.openldap.org/faq/index.cgi?file=1075>

# Note: most DB_CONFIG settings will take effect only upon rebuilding
# the DB environment.

# Set the database in memory cache size.
#
# set_cachesize <gbytes> <bytes> <ncache>
#   Sets the database in memory cache size.
#   Database entries and indexes will be stored in this cache to
#   avoid disk access during database read and write operations.
#   Tuning this value can greatly effect your database performance.
#   The parameters are:
#      <gbytes>: The number of gigabytes of memory to allocate to the cache.
#      <bytes>: The number of bytes of memory to allocate to the cache.
#      <ncache>: The number of cache segments to use. If this value is set to
#          0 or 1 then Berkeley DB will try to allocate one contiguous section
#          of memory for the cache. If this value is greater than 1, the cache
#          will be split into that number of segments.
%if %%getVar('import_slapadd', 'no') != 'no'
set_cachesize   2       0        1
%else
set_cachesize   %%db_cache_size_g   %%db_cache_size_o    %%db_cache_chunks
%end if

# Sets the database startup flags.
#
# set_flags <flag>
#   There are various flag options that may be set. The DB_TXN_NOSYNC flag
#   tells the database not to immediately flush transaction buffers to disk.
#   Setting this flag can help speed up database access during periods of
#   database write activity BUT at expense of data safety. Enable it only
#   to load data with slapadd, while slapd is not running.
%if %%getVar('import_slapadd', 'no') != 'no'
set_flags       DB_TXN_NOSYNC
%end if

# Data Directory
#set_data_dir db

# Set the maximum in memory cache in <bytes> for database file name caching.
#
# set_lg_regionmax <bytes>
#   This value should be increased as the number of database files increases
#   (tables and indexes).
set_lg_regionmax %%db_log_region_max
#
# Set the maximum size of log files in <bytes>.
#
# set_lg_max <bytes>
#   Logs will be rotated when <bytes> amount of data have been written to
#   one log file. This value should be at least four times the size of
#   set_lg_bsize.
#set_lg_max              10485760
set_lg_max   %%db_log_max

# Set the in memory cache for log information.
#
# set_lg_bsize <bytes>
#   When <bytes> amount of logging information have been written to this
#   cache it will be flushed to disk.
set_lg_bsize %%db_log_bsize

# Set the log file directory to <directory>.
#
# set_lg_dir              /usr/local/var/openldap-logs
#   Log files should preferably be on a different disk than the
#   database files. This both improves reliability (for disastrous
#   recovery) and speed of the database.
set_lg_dir %%db_log_directory

# Number of objects that can be locked at the same time.
set_lk_max_objects %%db_lk_max_objects
# Number of locks (both requested and granted)
set_lk_max_locks %%db_lk_max
# Number of lockers
set_lk_max_lockers %%db_lk_max_lockers

# Purge automatique des logs
set_flags       DB_LOG_AUTOREMOVE
