Liking cljdoc? Tell your friends :D

red claw

"... Red Claw managed to pull Batman's Cowl from his face"

<! release <! clojars>

redis clojure client based on redisson.

spilling the beans

$ make repl

=> (require '[redclaw.core :as rc]  ;; core functionality
            '[redclaw.data :as rd]) ;; working with data/structures

=> (def redis (rc/connect))  ;; by default will connect to a locally running redis on 6379 port
#'user/redis
;; a map
=> (def solar-system (rc/rmap redis "solar-system"))
#'user/solar-system

=> (rd/into solar-system {:saturn {:age 4503000000} :jupiter {:age 4603000000}})

=> solar-system
{:jupiter {:age 4603000000}, :saturn {:age 4503000000}}

=> (:jupiter solar-system)
{:age 4603000000}

clojure seq functions, such as into, for maps, sets, etc.. would work the same way they do on clojure seqs taking vectors and all:

;; a set
=> (def planets (rc/rset redis "planets"))
#'user/planets

=> (rd/into planets [:mercury :venus :earth :mars :jupiter :saturn :uranus :neptune])

=> planets
#{:uranus :jupiter :saturn :mercury :neptune :venus :mars :earth}

user=> (rd/conj planets :pluto)
true

;; now with pluto
user=> planets
#{:uranus :jupiter :saturn :mercury :neptune :pluto :venus :mars :earth}

redclaw.data also has one to one redisson mapped functions: add, add-all, get-all, etc..

looking inside the source (redis server):

127.0.0.1:6379> keys *
1) "planets"
2) "solar-system"

redis 127.0.0.1:6379> smembers "planets"
1) "\x04>\x05earth"
2) "\x04>\x05pluto"
3) "\x04>\ajupiter"
4) "\x04>\x06saturn"
5) "\x04>\x06uranus"
6) "\x04>\aneptune"
7) "\x04>\amercury"
8) "\x04>\x04mars"
9) "\x04>\x05venus"

license

Copyright © 2021 tolitius

Distributed under the Eclipse Public License either version 1.0 or (at your option) any later version.

Can you improve this documentation?Edit on GitHub

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close