BDB

Berkeley DB CFFI bindings

Example Usage (X Databases)

BDB-PLAYGROUND> (in-package :bdb-ext-playground)
#<PACKAGE "BDB-EXT-PLAYGROUND">
BDB-EXT-PLAYGROUND> (setq *env* (db-env-open "/home/main/tdb" 
                                             :init-txn t 
                                             :init-log t 
                                             :init-lock t 
                                             :init-mpool t 
                                             :create t 
                                             :buf-reader #'cbuf-reader 
                                             :buf-writer #'cbuf-writer))
#<BDB::DB-EXT-ENV {A92EEE1}>
BDB-EXT-PLAYGROUND> (setq *db* (db-open "test.db" :env *env* :auto-commit t :create t))
#<BDB::DB-EXT {ABB6459}>
BDB-EXT-PLAYGROUND> (db-put *db* 1 '(max mustermann))
T
BDB-EXT-PLAYGROUND> (db-put *db* 2 '(kater karlo))
T
BDB-EXT-PLAYGROUND> (db-get *db* 1)
(MAX MUSTERMANN)
BDB-EXT-PLAYGROUND> (db-get *db* 12)
NIL
BDB-EXT-PLAYGROUND> (db-get *db* 2)
(KATER KARLO)
BDB-EXT-PLAYGROUND> (db-get *db* 1)
(MAX MUSTERMANN)
BDB-EXT-PLAYGROUND> (db-get *db* 3)
NIL
BDB-EXT-PLAYGROUND> (setq *cursor* (db-cursor *db*))
#<BDB::EXT-CURSOR {B99BA91}>
BDB-EXT-PLAYGROUND> (db-cursor-get *cursor* :next t)
1
(MAX MUSTERMANN)
BDB-EXT-PLAYGROUND> (db-cursor-get *cursor* :next t)
2
(KATER KARLO)
BDB-EXT-PLAYGROUND> (db-cursor-get *cursor* :next t)
NIL
NIL
BDB-EXT-PLAYGROUND> (db-cursor-close *cursor*)
NIL
BDB-EXT-PLAYGROUND> (db-close *db*)
T
BDB-EXT-PLAYGROUND> (db-env-close *env*)
NIL
;;;; deleted database...
BDB-EXT-PLAYGROUND> (setq *env* (db-env-open "/home/main/tdb" 
                                             :init-txn t 
                                             :init-log t 
                                             :init-lock t 
                                             :init-mpool t 
                                             :create t 
                                             :buf-reader #'cbuf-reader 
                                             :buf-writer #'cbuf-writer))
#<BDB::DB-EXT-ENV {BC41169}>
BDB-EXT-PLAYGROUND> (setq *db* (db-open "test.db" :env *env* :auto-commit t :create t))
#<BDB::DB-EXT {BCF4141}>
BDB-EXT-PLAYGROUND> (setq *sdb* (db-open "stest.db" :env *env* :auto-commit t :create t :dup-sort t))
#<BDB::DB-EXT {BD4EA21}>
BDB-EXT-PLAYGROUND> (bdb:db-associate *db* *sdb* (lambda (db key data)
						   (values t (first data))))
T
BDB-EXT-PLAYGROUND> (db-put *db* 1 '(max mustermann))
T
BDB-EXT-PLAYGROUND> (db-put *db* 2 '(kater karlo))
T
BDB-EXT-PLAYGROUND> (db-get *db* 1)
(MAX MUSTERMANN)
BDB-EXT-PLAYGROUND> (setq *cursor* (db-cursor *db*))
#<BDB::EXT-CURSOR {ADE8121}>
BDB-EXT-PLAYGROUND> (db-cursor-get *cursor* :next t)
1
(MAX MUSTERMANN)
BDB-EXT-PLAYGROUND> (db-cursor-get *cursor* :next t)
2
(KATER KARLO)
BDB-EXT-PLAYGROUND> (db-cursor-get *cursor* :next t)
NIL
NIL
BDB-EXT-PLAYGROUND> (db-cursor-close *cursor*)
NIL
BDB-EXT-PLAYGROUND> (setq *cursor* (db-cursor *sdb*))
#<BDB::EXT-CURSOR {B728189}>
BDB-EXT-PLAYGROUND> (db-cursor-get *cursor* :next t)
KATER
(KATER KARLO)
BDB-EXT-PLAYGROUND> (db-cursor-get *cursor* :next t)
MAX
(MAX MUSTERMANN)
BDB-EXT-PLAYGROUND> (db-cursor-get *cursor* :next t)
NIL
NIL
BDB-EXT-PLAYGROUND> (db-cursor-close *cursor*)
T
BDB-EXT-PLAYGROUND> (db-close *sdb*)
T
BDB-EXT-PLAYGROUND> (db-close *db*)
T
BDB-EXT-PLAYGROUND> (db-env-close *env*)
NIL
BDB-EXT-PLAYGROUND> ;;bye bye
	

Valid XHTML 1.0 Strict