You could just write it as a function and leave out wcar*.
(defn batchly-redis [cmd params]
(doseq [params]
(apply cmd params)))
Then to execute:
(wcar* (batchly-redis cat/set parameters))
As far as I can tell, wcar is just a container macro, like with-open, in
that it initiates the connection and then cleans up after itself. Within
wcar, you can execute functions in whatever way you want.
- James
On 25 February 2014 09:00, 刘家财 <[email protected]> wrote:
> hi JW,
> First thank you for your reply.
> my origin question is somethine about redis.here i refer
> https://github.com/ptaoussanis/carmine
> I follow this two line
> (def server1-conn {:pool {<opts>} :spec {<opts>}}) ; See `wcar`
> docstring for opts
>
> (defmacro wcar* [& body] `(car/wcar server1-conn ~@body))
>
> then I can exec some redis commands,but I want to exec commands dynamicly.
> for example I here a vector [["foo" "bar"]["hello" "world"]]
> i want to exec following commands
> (wcar* (car/set "foo" "bar") (car/set "hello" "world"))
> so i have write a macro like this
>
> (defmacro batchly-redis [cmd params]
> (let [car-fns (map #(cons cmd %) params)]
> `(wcar* ~@car-fns)))
>
>
> then I can invoke this macro using this way
> (batchly-redis cat/set [["foo" "bar"]["hello" "world"]])
> in this way,my macro works ok.but here my vector is coming from the return
> of other fn ,so as you said above,this will not work, because marco
> evaluates args at compile time.Do your have some ideas on my problem.
> Really thanks
>
>
> 在 2014年2月24日星期一UTC+8下午6时29分09秒,Jozef Wagner写道:
>>
>> Well the evil thing is that apply-macro evaluates arguments at compile
>> time. Example where this won't work follows
>>
>> (defn foo [numbers]
>> (apply-macro + numbers))
>>
>> JW
>>
>>
>> On Mon, Feb 24, 2014 at 10:27 AM, 刘家财 <[email protected]> wrote:
>>
>>> I have one problem using Clojure
>>> we all know there is a apply for a fn to prepend intervening arguments
>>> to args.
>>> such as (apply + [2 3]) will equals to (+ 2 3)
>>> this is really handy,
>>> BUT,this is no apply-macro fn to use,I find a contrib(
>>> https://github.com/clojure/clojure-contrib/blob/
>>> 73accf597eafb8dfcb642702a3b98b057bbdbbdf/src/main/clojure/
>>> clojure/contrib/apply_macro.clj#L34) which has somethine like this,but
>>> deprecated.
>>> and says it is evil,I can't understand why the docs says it was evil?
>>> Is there anything harmful? Can someone show me some examples?
>>> Thank U
>>>
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Clojure" group.
>>> To post to this group, send email to [email protected]
>>>
>>> Note that posts from new members are moderated - please be patient with
>>> your first post.
>>> To unsubscribe from this group, send email to
>>> [email protected]
>>>
>>> For more options, visit this group at
>>> http://groups.google.com/group/clojure?hl=en
>>> ---
>>> You received this message because you are subscribed to the Google
>>> Groups "Clojure" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to [email protected].
>>>
>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>
>>
>> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to [email protected]
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/groups/opt_out.
>
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
---
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.