Next: , Up: User API Reference


5.1 Store Controllers

Store controllers provide the persistent storage for CLOS objects and BTree collections. Any persistent operations must be done in the context of a store controller. The default store-controller is stored in a global variable.

— Variable: elephant:*store-controller*

The store controller which persistent objects talk to.

Class elephant:store-controller is associated with the following user methods and macros:

— Macro: elephant:with-open-store spec &body body

Executes the body with an open controller, unconditionally closing the controller on exit.

— Function: elephant:open-store spec &rest args

Conveniently open a store controller. Set *store-controller* to the new controller unless it is already set (opening a second controller means you must keep track of controllers yourself. *store-controller* is a convenience variable for single-store applications or single-store per thread apps. Multi-store apps should either confine their *store-controller* to a given dynamic context or wrap each store-specific op in a transaction using with or ensure transaction. Returns the opened store controller.

— Function: elephant:close-store &optional sc

Conveniently close the store controller. If you pass a custom store controller, you are responsible for setting it to nil.

— Function: elephant:get-from-root key &key sc

Get the value associated with key from the root. Returns two values, the value, or nil, and a boolean indicating whether a value was found or not (so you know if nil is a value or an indication of non-presence)

— Function: elephant:add-to-root key value &key sc

Add an arbitrary persistent thing to the root, so you can retrieve it in a later session. Anything referenced by an object added to the root is considered reachable and thus live

— Function: elephant:remove-from-root key &key sc

Remove something from the root by the key value

— Function: elephant:root-existsp key &key sc

Test whether a given key is instantiated in the root

— Function: elephant:map-root fn &key sc

Takes a function of two arguments, key and value, to map over all key-value pairs in the root