Next: , Previous: DSR Registration, Up: Data Store API Reference

8.2 Store Controllers

Subclass store-controller and implement store and close controller which are called by open-store and close-store respectively.

— Class: elephant:store-controller

Class precedence list: store-controller, standard-object, t


Superclass for the data store controller, the main interface to any book-keeping, references to db handles, the instance cache, btree table creation, counters, locks, the roots (for garbage collection,) et cetera. Behavior is shared between the superclass and subclasses. See slot documentation for details.

— Generic Function: elephant-data-store:open-controller sc &key recover recover-fatal thread &allow-other-keys

Opens the underlying environment and all the necessary database tables. Different data stores may use different keys so all methods should &allow-other-keys. There are three standard keywords: :recover, :recover-fatal and :thread. Recover means that recovery should be checked for or performed on startup. Recover fatal means a full rebuild from log files is requested. Thread merely indicates to the data store that it is a threaded application and any steps that need to be taken (for example transaction implementation) are taken. :thread is usually true.

— Generic Function: elephant-data-store:close-controller sc

Close the db handles and environment. Should be in a state where lisp could be shut down without causing an inconsistent state in the db. Also, the object could be used by open-controller to reopen the database

— Generic Function: elephant-data-store:connection-is-indeed-open controller

Validate the controller and the db that it is connected to

For upgrading and opening legacy databases it is important that a store be able to indicate which version of elephant was used to create it. This governs the chosen serializer, mappings between elephant symbols used in an old vs. new version, etc. Because this is called to initialize the serializer, it must directly implemented by the data store without using the serializer.

— Generic Function: elephant-data-store:database-version sc

Data stores implement this to store the serializer version. The protocol requires that data stores report their database version. On new database creation, the database is written with the *elephant-code-version* so that is returned by database-version. If a legacy database does not have a version according to the method then it should return nil

— Method: around elephant-data-store:database-version sc

Default version assumption for unmarked databases is 0.6.0. It is possible to check for 0.5.0 databases, but it is not implemented now due to the low (none?) number of users still on 0.5.0

There are some utilities for serializing simple data without a serializer using the memutil package.

— Function: elephant-data-store:serialize-database-version-key bs

Given a buffer-stream, encode a key indicating the version using the constant +elephant-version+

— Function: elephant-data-store:serialize-database-version-value version bs

Serializes a list containing three integers to the buffer stream bs

— Function: elephant-data-store:deserialize-database-version-value bs

Deserializes the 3 integer list from buffer stream bs