Created
August 9, 2010 14:19
-
-
Save isterin/515468 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defclass kc-dbm () | |
() | |
(:documentation "A KC database.")) | |
(defclass kc-bdb (kc-dbm) | |
() | |
(:documentation "A KC B+ tree database.")) | |
(defclass kc-hdb (kc-dbm) | |
() | |
(:documentation "A KC hash database.")) | |
(defgeneric put (db key value &key mode)) | |
(defmethod put ((db kc-bdb) key value &key mode) | |
(funcall (put-method-for db mode) key value)) | |
(defmethod put ((db kc-hdb) key value &key mode) | |
(funcall (put-method-for db mode) key value)) | |
(defgeneric put-method-for (mode) | |
(:method ((db kc-bdb) (mode (eql :replace))) #'bdbset) | |
(:method ((db kc-bdb) (mode (eql :keep))) #'bdbadd) | |
(:method ((db-kc-bdb) (mode (eql :concat))) #'bdbappend) | |
(:method ((db kc-hdb) (mode (eql :replace))) #'hdbset) | |
(:method ((db kc-hdb) (mode (eql :keep))) #'hdbadd) | |
(:method ((db-kc-hdb) (mode (eql :concat))) #'hdbappend)) | |
;; definitions of methods for kcdbset, kcdbadd, and kcdbappend define methods | |
;; that store key/value pairs with different behaviors based on whether | |
;; that key already exists. | |
;; For more info see: http://github.com/isterin/cl-kyoto-cabinet | |
;; Usage... | |
(defparameter *kchdb* (make-instance 'kc-hdb)) | |
(defparameter *kcbdb* (make-instance 'kc-bdb)) | |
;; Will store some_val under some_key | |
(put *kchdb* "some_key" "some_val" :mode :replace) | |
(put *kchdb* "some_key" "some_val" :mode :keep) | |
(put *kcbdb* "some_key" "some_val" :mode :replace) | |
(put *kcbdb* "some_key" "some_val" :mode :concat) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment