clojure redis 使用-carmine


现在clojure连接 redis的工具有redis-clojureclj-redis based on JedisAccession, 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>}}) 

这里可以让我找了半天的地方,在他的api文档中找到,他需要配置的格式可以参考下面

`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"))




ok,完工。


 


  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值