Git has a built-in persistent store for objects based on Merkle trees. It is tailored to store files and directories, but these are just specializations of trees of blobs. There is no reason it couldn't be used to store Lisp objects.
Githack
is a Lisp object store that uses Git as its backend. It is a simple
library that provides persistent objects for Lisp and a
transactional interface for manipulating them. Simple atomic objects
are stored as blobs and composite objects are stored as
trees. Standard composite Lisp objects, such as lists, vectors, and
hash tables, are supported. Custom composite objects can be created
through DEFINE-PERSISTENT-STRUCT
or DEFCLASS with
a :STANDARD-PERSISTENT-METACLASS.
WITH-REPOSITORY is used to specify which repository to
use for storing objects. WITH-TRANSACTION sets up a
transaction for manipulating objects and retrieves the root
object. You use standard slot accessors to walk the object
tree. When you are done, you commit the transaction, and
modifications are atomically written to the repository with a new
root object being placed in a Git branch.
By placing the database in an orphan Git branch, you can store it
right beside your source code without tangling the histories. You
can use Git to manage the history of the database, branch it, and
share it with others. Githack even stores object docstrings
as README.md files inside the repository trees, so the
stored objects are natively self-documenting in the Git web UI.
Githack comes with example code and an example database living on its own orphan branch, so if you clone the repository, you'll clone the working example database as well.
No comments:
Post a Comment