chickadee » level » db-batch

db-batch db ops #!key (sync #f)procedure

When making multiple changes that rely on each other you can apply a batch of operations atomically using db-batch. The ops argument is a list of operations which will be applied in order (meaning you can create then later delete a value in the same batch, for example).

    
(define myops '((put "abc" "123")
                (put "def" "456")
                (delete "abc")))

;; apply all operations in myops
(db-batch db myops)

The first item in an operation should be the symbol put or delete, any other value will give an error. The next item is the key and in the case of put the third item is the value.

Apart from its atomicity benefits, db-batch may also be used to speed up bulk updates by placing lots of individual mutations into the same batch.