Skip to content
Browse files

Fix destructuring of init.

  • Loading branch information...
1 parent ebcf1d6 commit e7dc332832842269ea5bc8e278af9d8d4776c95d @technomancy technomancy committed
Showing with 15 additions and 11 deletions.
  1. +15 −11 src/clj_redis/client.clj
View
26 src/clj_redis/client.clj
@@ -7,17 +7,21 @@
(def ^{:private true} local-url
"redis://127.0.0.1:6379")
-(defn init [& [{:keys [url timeout test-on-borrow] :as opts}]]
- (let [uri (URI. (or url local-url))
- tout (or timeout 2000)
- host (.getHost uri)
- port (.getPort uri)
- uinfo (.getUserInfo uri)
- pass (and uinfo (last (str/split uinfo #":")))
- config (JedisPoolConfig.)]
- (when test-on-borrow
- (.setTestOnBorrow config test-on-borrow))
- (JedisPool. config host port tout pass)))
+(defn init
+ ([] (init {}))
+ ([{:keys [url timeout test-on-borrow] :as opts}]
+ (let [uri (URI. (or url local-url))
+ tout (or timeout 2000)
+ host (.getHost uri)
+ port (.getPort uri)
+ uinfo (.getUserInfo uri)
+ pass (and uinfo (last (str/split uinfo #":")))
+ config (JedisPoolConfig.)]
+ (when test-on-borrow
+ (.setTestOnBorrow config test-on-borrow))
+ (JedisPool. config host port tout pass)))
+ ([k1 v1 & {:as opts}]
+ (init (assoc opts k1 v1))))
(defn lease [^JedisPool p f]
(let [j (.getResource p)]

0 comments on commit e7dc332

Please sign in to comment.
Something went wrong with that request. Please try again.