Skip to content

Commit

Permalink
add test-on-borrow as config opt
Browse files Browse the repository at this point in the history
  • Loading branch information
mpenet authored and mmcgrana committed May 8, 2011
1 parent b179fc3 commit 760c440
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/clj_redis/client.clj
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,17 @@
(def ^{:private true} local-url
"redis://127.0.0.1:6379")

(defn init [& [{:keys [url timeout] :as opts}]]
(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.)
pool (JedisPool. config host port tout pass)]
pool))
config (JedisPoolConfig.)]
(when test-on-borrow
(.setTestOnBorrow config test-on-borrow))
(JedisPool. config host port tout pass)))

(defn lease [^JedisPool p f]
(let [j (.getResource p)]
Expand Down

0 comments on commit 760c440

Please sign in to comment.