https://github.com/multimethod/cl-sophia.git
git clone 'https://github.com/multimethod/cl-sophia.git'
(ql:quickload :cl-sophia)
Common Lisp high-level API for Sophia key-value storage
$ cd install
$ make
$ sudo make install
(ql:quickload "cl-sophia")
(with-database ("test")
(setf ($ "x") "a"
($ "y") "b")
(values ($ "x")
($ "y")
($ "z")))
;; => "a"
;; => "b"
;; => NIL
(with-database ("test")
(setf ($ "x") "a")
(let ((x ($ "x")))
(setf ($ "x") nil)
(values x ($ "x"))))
;; => "a"
;; => NIL
(with-database ("test" :comparator :u32)
(with-transaction ()
(setf ($ 0) "a"
($ 1) "b"
($ 2) "c"))
(ignore-errors
(with-transaction ()
(setf ($ 1) nil)
(error "Bam!")))
(values ($ 0)
($ 1)
($ 2)))
;; => "a"
;; => "b"
;; => "c"
(with-database ("test")
(with-transaction ()
(setf ($ "x") "foo"
($ "y") "bar")
(with-transaction ()
(setf ($ "z") "baz")))
(values ($ "x")
($ "y")
($ "z")))
;; => "foo"
;; => "bar"
;; => "baz"
(with-database ("test" :comparator :u32)
(dotimes (i 3)
(setf ($ i) (format nil "~r" i)))
(let (result)
(let ((*order* :>=)) ; by default
(map-object (lambda (key value)
(push (cons key value) result))))
(values result)))
;; => ((2 . "two") (1 . "one") (0 . "zero"))