Using the Memory Backend
The Memory backend stores directory entries only in the OpenDJ server process memory. Use it for small development datasets, isolated tests, disposable demonstrations, or temporary data that can be recreated.
|
The Memory backend has no persistence. All entries, including the base entry, are discarded when the backend is disabled, when it is enabled, and when OpenDJ restarts. Re-enabling the backend starts with an empty dataset. Do not use it for a production suffix that requires durable directory storage. |
Saving the backend configuration does not save its entries. Keeping an LDIF file on disk does not make the Memory backend reload that file automatically; populate the running backend again after each reset.
The implementation is intended for small datasets and does not provide configurable attribute indexes. Searches other than base-object searches scan the dataset. Choose a database backend when you need indexed searches over larger datasets.
Creating a Memory Backend
Run the following commands from the OpenDJ installation directory on a running test instance. The examples use the administration connector on port 4444, LDAP with StartTLS on port 1389, and the demonstration credentials cn=Directory Manager / password. Adjust these values for your instance. The --trustAll option is for the self-signed certificate in this local test.
Choose a unique backend name and a base DN that is not already assigned to another backend. The Memory backend implementation requires exactly one base DN. This example uses temporaryData and dc=memory,dc=example:
bin/dsconfig create-backend \
--hostname localhost --port 4444 \
--bindDN 'cn=Directory Manager' --bindPassword password \
--backend-name temporaryData --type memory \
--set base-dn:dc=memory,dc=example \
--set enabled:true --set writability-mode:enabled \
--trustAll --no-prompt
The backend is initially empty. Configuring base-dn registers the naming context; it does not create its base entry. writability-mode:enabled permits supported write operations, subject to the global writability mode and the client’s access rights.
For the complete property list, defaults, and constraints, see Memory backend creation properties and Memory backend property updates in the generated dsconfig reference.
Populating and Verifying the Backend
Create memory-data.ldif with the base entry followed by a child entry:
dn: dc=memory,dc=example
objectClass: top
objectClass: domain
dc: memory
dn: ou=People,dc=memory,dc=example
objectClass: top
objectClass: organizationalUnit
ou: People
Add the entries through LDAP while the backend is enabled, then search the naming context:
bin/ldapmodify \
--hostname localhost --port 1389 --useStartTLS --trustAll \
--bindDN 'cn=Directory Manager' --bindPassword password \
--defaultAdd --filename memory-data.ldif
bin/ldapsearch \
--hostname localhost --port 1389 --useStartTLS --trustAll \
--bindDN 'cn=Directory Manager' --bindPassword password \
--baseDN 'dc=memory,dc=example' --searchScope sub \
'(objectClass=*)' dc ou
The search returns both entries:
dn: dc=memory,dc=example
dc: memory
dn: ou=People,dc=memory,dc=example
ou: People
Repeating the add while these entries still exist reports Entry Already Exists. Keep the source file if you want to recreate the same disposable dataset later.
Resetting the Dataset
On the disposable backend created above, disabling and re-enabling it clears the entries:
bin/dsconfig set-backend-prop \
--hostname localhost --port 4444 \
--bindDN 'cn=Directory Manager' --bindPassword password \
--backend-name temporaryData --set enabled:false \
--trustAll --no-prompt
bin/dsconfig set-backend-prop \
--hostname localhost --port 4444 \
--bindDN 'cn=Directory Manager' --bindPassword password \
--backend-name temporaryData --set enabled:true \
--trustAll --no-prompt
Repeat the search from the previous section. It now returns No Such Entry (LDAP result code 32), because even the base entry has been discarded. Run the ldapmodify command again to reload both entries. Restarting OpenDJ also clears the dataset and requires another reload.
Choosing Storage and Routing
| Backend | When to use it |
|---|---|
Memory |
Small, disposable datasets held only in server memory. Entries are lost on backend disablement, enablement, and server restart. |
LDIF |
A small directory backed by an LDIF file, such as static namespace entries. Unlike Memory, its configured file supplies entries when the backend starts; supported writes update that file. |
JE or PDB |
Persistent local database storage for directory suffixes, with database indexes. See Creating a New Database Backend. |
JDBC |
Directory data stored in a supported relational database. See Use a Relational Database as an LDAP Backend. |
Cassandra |
Directory data stored in a Cassandra cluster. See Store Directory Data in Cassandra. |
For JDBC and Cassandra, configure the database or cluster’s persistence and availability to meet your requirements. A Memory backend can hold a temporary branch beneath a local parent backend, but its entries disappear on reset. Use durable storage for entries that must survive a restart. See Subordinate Backends.