Closed bcambel closed 8 years ago
Hi Bahadir,
There's an in-depth example at http://redis.io/commands/scan - is that helpful?
Thanks for the link, that was what I was reading to figure out as well and come up with the following code.
(loop [ idx 0 curs 0 dataset []]
(let [[curs data] (wcar* (car/scan curs))]
(info curs)
(if-not (< idx 10)
(into dataset data)
(recur (inc idx) curs (into dataset data)))))
which helped to fetch the keys continuously.
But my initial problem with the call was while I was trying to search via a pattern;
(wcar*
(car/scan 0 "*booking*" ))
returns an Exception ; ExceptionInfo ERR syntax error clojure.core/ex-info
normally the following Redis command scan 0 MATCH *booking*
returns matching results.
I am using Redis 2.8.19 and Carmine [com.taoensso/carmine "2.11.1"]
Thanks Peter for your time!
I haven't used the scan API myself, but skimming the docs + that error it looks like your syntax might be off here?:
(wcar* (car/scan 0 "*booking*" )) ; => ExceptionInfo ERR syntax error clojure.core/ex-info
Docs say the syntax is SCAN cursor [MATCH pattern] [COUNT count]
i.e. The valid arities appear to be: 1, 3 or 5 but you've got arity 2.
Again, have never used this - but I'd start by confirming that you've got the right call.
Count is optional and not reliable. The default is 10; if you pass COUNT 1, it might return 2 elements.
The problem might be that Redis expects the MATCH and COUNT words as an argument as well where carmine only passes the values ?
In (wcar* {} (car/scan 0 "*booking*" ))
you're calling scan
with 2 arguments; that's not a valid arity. You need to call it with 1 argument (wcar* {} (car/scan 0))
, 3 (with :match+pattern or :count+count), or 5 (both :match+pattern AND :count+count).
(wcar* {} (car/scan 0 "*booking*" ))
will throw, because it's an invalid Redis call (arity 2).
(wcar* {} (car/scan 0))
will return a result (arity 1).
(wcar* {} (car/scan 0 :match "booking*"))
will return a result (arity 3).
(wcar* {} (car/scan 0 :count 3))
will return a result (arity 3).
(wcar* {} (car/scan 0 :match "booking*" :count 3))
will return a result (arity 5).
Does that make sense?
Well that makes sense. Thanks Peter!
On Thu, Aug 6, 2015 at 4:14 PM, Peter Taoussanis notifications@github.com wrote:
In (wcar* {} (car/scan 0 "booking" )) you're calling scan with 2 arguments; that's not a valid arity. You need to call it with 1 argument (wcar* {} (car/scan 0)), 3 (with :match+pattern or :count+count), or 5 (both :match+pattern AND :count+count).
(wcar* {} (car/scan 0 "booking" )) will throw, because it's an invalid Redis call (arity 2). (wcar* {} (car/scan 0)) will return a result (arity 1). (wcar* {} (car/scan 0 :match "booking")) will return a result (arity 3). (wcar {} (car/scan 0 :count 3)) will return a result (arity 3). (wcar* {} (car/scan 0 :match "booking*" :count 3)) will return a result (arity 5).
Does that make sense?
— Reply to this email directly or view it on GitHub https://github.com/ptaoussanis/carmine/issues/139#issuecomment-128383015 .
Regards , Bahadir Cambel
Great, no problem! Feel free to ping if you run into any other issues, cheers! :-)
It would be so great to have an example of the scan function ? Any examples you can point me out ? Thanks in advance