Library for transaction-oriented data bases.
1ExplanationClobber is an alternative to so-called "object prevalence", and inparticular to cl-prevalence.
Clobber is both simpler, more flexible, and more robust than systems based on object prevalence.
1.1SimplicityClobber is simpler because we do not take any snapshots at all. Othersystems typically use a combination of transaction logs and snapshots.Clobber uses only a transaction log which is always read into an emptysystem.
1.2FlexibilityClobber is more flexible because the system itself does not define theformat of a transaction. Client code can save transactions as Lisplists, as instances of standard-object, or anything else that can beserialized. It is also more flexible because transactions can containany object that can be serialized, including model objects. With thismethod, client code does not need to manipulate "manually createdpointers" such as social security numbers, account numbers, membershipnumbers, etc. whenever it needs to execute a transaction. Instead itcan use the model objects themselves such as people, accounts,automobiles and whatnot.
1.3RobustnessClobber is more robust because serialization of instances of (subclassesof)
standard-objectis not accomplished based on slots. Clobber considers slots to beimplementation details. In other object prevalence systems, wheneverthe model evolves, the serialization might no longer be valid. Incontrast, Clobber serializes instances of
standard-objectas a list ofpairs, each one consisting of an initarg and a value. These pairs canbe handled by client code in any way it sees fit. They can be handledby an
initialize-instance, or they can be ignored. Thedownside of the Clobber method is that client code must specify thesepairs in the form of an initarg and the name of an accessor functionto be called to obtain the value used for the initarg. Thisinconvenience is however relatively minor, especially considering theadditional robustness it buys in terms of less sensitivity to changesin the model classes.
1.4DesignAt the heart of Clobber is a mechanism for serializing objects thatpreserves object identity, much like the reader macros
##,except that Clobber detects sharing within the entire transaction log,not only within a single transaction. This mechanism is what makes itpossible for client code to put any old object in a transaction, whilemaking sure that sharing is preserved.
1.5ExamplesTwo examples are included - see files demo.lisp and demo2.lisp
(ql:quickload :clobber) (in-package :clobber-demo) (start "/path/to/new/file") (do-things-1) ;; inspect the file to see the transaction log
1.6LicenseClobber is in the public domain in countries where it is possible toplace works in the public domain explicitly. In other countries, wewill distribute Clobber according to a license that lets the user dowhatever he or she pleases with the code.
1.7ContactSend comments to email@example.com
A manual might be written one day.
2How to use Clobber
- If your application objects are instances of (subclasses of)
clobber:define-save-infoto tell Clobber how to serialize them.
- Determine the data structure your application will use to represent each transaction, and how the application will restore state from each transaction.
e.g. a transaction could be a list whose
caris a function and whose
cdris a list of arguments to the function. State can be restored from such a transaction through
(lambda (txn) (apply (first txn) (rest txn)))
- When you update your application state -
clobber:with-transaction-logto create a transaction log.
- Within the body of
clobber:log-transactionto persist the changes to your application state. You may wish to define a helper function or macro for this.
clobber:with-transaction-log is for some reason unsuitable -
clobber:open-transaction-logto create a transaction log, usually stored in a special variable.
clobber:log-transactionto persist changes to your application state.
- When the transaction log is no longer required, close it using