Next: DSR Handling Serialization, Previous: DSR Registration, Up: Data Store API Reference
Subclass store-controller and implement store and close controller which are called by open-store and close-store respectively.
Class precedence list:
store-controller, standard-object, t
Slots:
spec
— initargs::spec
Data store initialization functions are expected to initialize :spec on the call to make-instance
root
This is an instance of the data store persistent btree. It should have an
oid
that is fixed in the code and does not change between sessions. Usually it this is something like 0, 1 or -1class-root
This is another root for class indexing that is also a data store specific persistent btree instance with a unique
oid
that persists between sessions.instance-cache
This is an instance cache and part of the metaclass protocol. Data stores should not override the default behavior.
instance-cache-lock
Protection for updates to the cache from multiple threads. Do not override.
serializer-version
Governs the default behavior regarding which serializer version the current elephant core is using. Data stores can override by creating a method on initialize-serializer.
serialize
Accessed by elephant::serialize to get the entry point to the default serializer or to a data store specific serializer
deserialize
Contains the entry point for the specific serializer to be called by elephant::deserialize
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.
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.
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
Ensure the classes don't have stale references to closed stores!
Delete connection spec so store-controller operations on cached controller information fail
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.
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
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.
Given a buffer-stream, encode a key indicating the version using the constant +elephant-version+