Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

init

  • Loading branch information...
commit 3652505a3d3b01a8b4fd0bbcadd95f6050571638 0 parents
@mmcgrana authored
Showing with 48 additions and 0 deletions.
  1. +1 −0  .gitignore
  2. +4 −0 project.clj
  3. +22 −0 readme.md
  4. +21 −0 src/clj_redis/client.clj
1  .gitignore
@@ -0,0 +1 @@
+lib
4 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 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 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))
Please sign in to comment.
Something went wrong with that request. Please try again.