-
-
Save jefftriplett/107941 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
; A wrapper to access Tokyo Cabinet from clojure | |
(ns tokyo-cabinet | |
; exclude symbols we'll use in our API | |
(:refer-clojure :exclude [use get])) | |
(declare *db*) | |
(defn get [key] (.get *db* key)) | |
(defn put [key value] (.put *db* key value)) | |
(defmacro use [filename & body] | |
(import '(tokyocabinet HDB)) | |
`(with-open [hdb# (HDB.)] | |
(.open hdb# ~filename (bit-or HDB/OWRITER HDB/OCREAT)) | |
(binding [*db* hdb#] | |
(do ~@body)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment