现在clojure连接 redis的工具有redis-clojure, clj-redis based on Jedis, Accession, and (the newest) labs-redis-clojure.
但是在我看来carmine文档比较丰富,所以使用他,https://github.com/ptaoussanis/carmine
现在project.clj中 添加
[com.taoensso/carmine "2.4.5"](需要有lein安装)
在自己的clj文件中添加
(ns my-app (:require [taoensso.carmine :as car :refer (wcar)]))
(def server1-conn {:pool {<opts>} :spec {<opts>}})
`conn` arg is a map with connection pool and spec options:
{:pool {} :spec {:host "127.0.0.1" :port 6379}} ; Default
{:pool {} :spec {:uri "redis://redistogo:pass@panga.redistogo.com:9475/"}}
{:pool {} :spec {:host "127.0.0.1" :port 6379
:password "secret"
:timeout-ms 6000
:db 3}}
A `nil` or `{}` `conn` or opts will use defaults. A `:none` pool can be used
to skip connection pooling. For other pool options, Ref. http://goo.gl/EiTbn.
(defmacro wcar* [& body] `(car/wcar server1-conn ~@body))
测试
(wcar* (car/ping)
(car/set "foo" "bar")
(car/get "foo"))
再标注下一般我在java中的hget使用格式也记录下
(wcar* (car/hget "bid" "91801"))