Created
August 6, 2010 01:50
-
-
Save isterin/510707 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
(defgeneric put-method-for (mode) | |
(:method ((mode (eql :replace))) #'kcdbset) | |
(:method ((mode (eql :keep))) #'kcdbadd) | |
(:method ((mode (eql :concat))) #'kcdbappend)) | |
(defun put (key value &key (mode :replace)) | |
(funcall (put-method-for mode) key value)) | |
;; 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... | |
;; Will store some_val under some_key | |
(put "some_key" "some_val" :mode :replace) | |
;; Will not do anything, as it will invoke kcdbadd, which does | |
;; nothing if the key exists | |
(put "some_key" "some_val" :mode :keep) | |
;; Will add some_val2 to some_key by using kcdbappend | |
(put "some_key" "some_val2" :mode :concat) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment