Skip to content

Instantly share code, notes, and snippets.

@ejackson
Created April 1, 2011 10:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ejackson/897978 to your computer and use it in GitHub Desktop.
Save ejackson/897978 to your computer and use it in GitHub Desktop.
;;------------------------------------------------------------------------------
(declare *connection*)
(defmacro with-redis
([host func]
`(binding [*connection* (Jedis. ~host)]
(try
(~@func)
(finally
(.disconnect *connection*))))))
(defmacro redis* [host name & args]
`(with-redis
~host
(. *connection* ~name ~@args)))
(defmacro create-redis [host]
`(defmacro redis [n# & args#]
`(redis* ~~host ~n# ~@args#)))
(redis keys "*")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment