Strange behavior in carmine (clojure-redis client)

135 Views Asked by At

Consider this snippet in carmine

(wcar* (car/set "counter" 1)            ;; expect to be number counter=1
       (let [id (car/get "counter")]    ;; expect to have id=1
         (println id)))                 ;; [nil [[SET counter 1] [GET counter]]]

What I am doing wrong here? Is there a way to use let inside wcar* macro?

1

There are 1 best solutions below

2
On

You can nest wcar forms which gives you access to the return values inside wcar:

(wcar*
  (car/set "counter" 1)
  (let [id (wcar*
             (car/get "counter"))]
    (println id)
    id))