WARNING: this 'native' kind of using secondary databases with Berkeley DB is very C-centric, thus for
every callback function you create, cffi will create one and those functions and associated data (when using closures for example)
will not being garbage collected, even if databases were closed. Thus if you use alot of secondary databases, there may be
a lot of garbage being produced over time...
Using transactional databases, C-Style callbacks are not used anymore and you must not be "afraid" about anything...
CL-USER> (asdf:oos 'asdf:load-op :bdb-playground) NIL CL-USER> (in-package :bdb-playground) #<PACKAGE "BDB-PLAYGROUND"> BDB-PLAYGROUND> (defun first-callback (sdb key data) (values t (first data))) FIRST-CALLBACK BDB-PLAYGROUND> (setq *callback* (create-assoc-callback #'first-callback)) #.(SB-SYS:INT-SAP #X050006F8) BDB-PLAYGROUND> (setq *db* (db-open "test.db" :create t :exclusive t)) #<DB-STD {A866C31}> BDB-PLAYGROUND> (setq *sdb* (db-open "sec.db" :create t :exclusive t :dup-sort t)) #<DB-STD {A9DEB49}> BDB-PLAYGROUND> (db-associate *db* *sdb* *callback*) T BDB-PLAYGROUND> (db-put *db* 1 '(max mustermann)) T BDB-PLAYGROUND> (db-put *db* 2 '(kater karlo)) T BDB-PLAYGROUND> (db-put *db* 3 '(micky maus)) T BDB-PLAYGROUND> (setq *cursor* (db-cursor *db*)) #<BDB::CURSOR {B350ED1}> BDB-PLAYGROUND> (db-cursor-get *cursor* :next t) 1 (MAX MUSTERMANN) BDB-PLAYGROUND> (db-cursor-get *cursor* :next t) 2 (KATER KARLO) BDB-PLAYGROUND> (db-cursor-get *cursor* :next t) 3 (MICKY MAUS) BDB-PLAYGROUND> (db-cursor-get *cursor* :next t) NIL NIL BDB-PLAYGROUND> (db-cursor-close *cursor*) NIL BDB-PLAYGROUND> (setq *cursor* (db-cursor *sdb*)) #<BDB::CURSOR {B4CF249}> BDB-PLAYGROUND> (db-cursor-get *cursor* :next t) KATER (KATER KARLO) BDB-PLAYGROUND> (db-cursor-get *cursor* :next t) MICKY (MICKY MAUS) BDB-PLAYGROUND> (db-cursor-get *cursor* :next t) MAX (MAX MUSTERMANN) BDB-PLAYGROUND> (db-cursor-get *cursor* :next t) NIL NIL BDB-PLAYGROUND> (db-cursor-close *cursor*) NIL BDB-PLAYGROUND> (db-close *sdb*) NIL BDB-PLAYGROUND> (db-close *db*) NIL BDB-PLAYGROUND> ;;bye bye