Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
mmcgrana committed Dec 26, 2010
0 parents commit 3652505
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
@@ -0,0 +1 @@
lib
4 changes: 4 additions & 0 deletions project.clj
@@ -0,0 +1,4 @@
(defproject clj-redis "0.0.1"
:dependencies
[[org.clojure/clojure "1.3.0-alpha4"]
[redis.clients/jedis "1.3.0"]])
22 changes: 22 additions & 0 deletions readme.md
@@ -0,0 +1,22 @@
# clj-redis

Clojure Redis client library.

## Usage

(require '[clj-redis.client :as redis])

(def db (redis/init))

(redis/ping db)
=> "PONG"

(redis/set db "foo" "BAR")
=> "OK"

(redis/get db "foo")
=> "BAR"

## Installation

Depend on `[clj-redis "0.0.1"]` in your `project.clj`.
21 changes: 21 additions & 0 deletions src/clj_redis/client.clj
@@ -0,0 +1,21 @@
(ns clj-redis.client
(:import java.net.URI)
(:import redis.clients.jedis.Jedis)
(:refer-clojure :exclude [get set]))

(def ^:private local-url "redis://127.0.0.1:6379")

(defn init [& [{:keys [url] :as opts}]]
(let [u (URI. (or url local-url))
h (.getHost u)
p (.getPort u)]
(Jedis. h p)))

(defn ping [r]
(.ping r))

(defn set [r k v]
(.set r k v))

(defn get [r k]
(.get r k))

0 comments on commit 3652505

Please sign in to comment.