]> git.saurik.com Git - redis.git/blob - client-libraries/clojure/examples/demo.clj
Clojure library thanks to Ragnar Dahlén
[redis.git] / client-libraries / clojure / examples / demo.clj
1 ;;
2 ;; Simple demo of redis-clojure functionality
3 ;;
4 ;; Make sure redis-clojure.jar or the contents of the src/ directory
5 ;; is on the classpath.
6 ;;
7 ;; Either:
8 ;; (add-classpath "file:///path/to/redis-clojure.jar"
9 ;; or:
10 ;; (add-classpath "file:///path/to/redis/src-dir/")
11 ;;
12
13 (add-classpath "file:///Users/ragge/Projects/clojure/redis-clojure/redis-clojure.jar")
14
15 (ns demo
16 (:require redis))
17
18
19 (redis/with-server
20 {:host "127.0.0.1" :port 6379 :db 0}
21 (do
22 (println "Sending ping")
23 (println "Reply:" (redis/ping))
24 (println "Server info:")
25 (let [info (redis/info)]
26 (dorun
27 (map (fn [entry]
28 (println (str "- "(first entry) ": " (last entry)))) info)))
29 (println "Setting key 'foo' to 'bar'")
30 (println "Reply:" (redis/set "foo" "bar"))
31 (println "Getting value of key 'foo'")
32 (println "Reply:" (redis/get "foo"))))
33