Created
April 5, 2011 03:08
-
-
Save hboon/902956 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
; a macro in redis-clojure. | |
(defmacro with-connection [name pool server-spec & body] | |
`(let [~name (get-connection ~pool ~server-spec)] | |
(try | |
~@body | |
(catch Exception e# | |
; if we reach here, i.e. an exception, we don't want to run (release-connection) in finally | |
(release-connection ~pool ~name e#) | |
(throw e#)) | |
(finally | |
; don't execute the following if there is any exception above | |
(release-connection ~pool ~name))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment