taoensso / carmine

Redis client + message queue for Clojure
https://www.taoensso.com/carmine
Eclipse Public License 1.0
1.15k stars 130 forks source link

Unexpected behavior #182

Closed JGailor closed 7 years ago

JGailor commented 7 years ago

Trying to get the members of a set and sequentially process them like so:

(wcar* (doseq [member (car/smembers "my-set")] (println member)))
=> nil
[[SMEMBERS my-set]]
["1" "2" "3" "5" "6" "7" "8" "9" "10"]

It's been a while since I have written Clojure but can someone give me an idea of what I'm doing wrong? If I simplify the expression to just

(wcar* (car/smembers "my-set"))
=> ["1" "2" "3" "5" "6" "7" "8" "9" "10"]

and digging further into it:

(class (wcar* (car/smembers "my-set")))
=> clojure.lang.PersistentVector

I'm a bit confused by what the doseq is doing differently that's resulting in the two vectors being returned.

ptaoussanis commented 7 years ago

(wcar* (doseq [member (car/smembers "my-set")](println member)))

Hi there! Please see the Carmine README for usage instructions.

car/command calls have a nil result within a wcar call. The server reply that you're looking for is returned only with the enclosing wcar call.

One wcar => one TCP roundtrip. No replies are actually received from the server until the wcar form terminates.

Hope that helps!

JGailor commented 7 years ago

Huge help.  Makes total sense.  Thanks for pointing that out.

Get Outlook for iOS

On Mon, Aug 1, 2016 at 7:54 PM -0700, "Peter Taoussanis" notifications@github.com wrote:

(wcar* (doseq member (car/smembers "my-set")))

Hi there! Please see the Carmine README for usage instructions.

car/command calls have a nil result within a wcar call. The server reply that you're looking for is returned only with the enclosing wcar call.

One wcar => one TCP roundtrip. No commands are actually sent to the server until the wcar form terminates.

Hope that helps!

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

ptaoussanis commented 7 years ago

No problem :-)