bwlewis / rredis

R client for Redis
http://illposed.net/
93 stars 25 forks source link

Insert multiple list items #19

Closed igorper closed 10 years ago

igorper commented 10 years ago

It seems like inserting multiple list elements is not possible with the current redisLPush/redisRPush implementation (despite this being supported in redis).

Would it make sense to implement this (e.g. by breaking a vector of values into individual list items and inserting them)? A flag could be used to enable this option (to provide backwards compatibility).

bwlewis commented 10 years ago

You're right, an oversight on my part. I think this is a good idea.

I'm working on some performance-related weirdness with the new 'nodelay' option in redisConnect. As soon as I finish that, I'll add this to the list push functions (maybe this weekend?).

Cheers,

Bryan

igorper commented 10 years ago

That's perfect!

bwlewis commented 10 years ago

Sorry it took so long, I got tied up with some other projects.

The new syntax is:

redisLPush(key, value, ...) redisRPush(key, value, ...)

where ... indicates optional additional values. It's not enough to just supply value as a list or vector, because of course lists and vectors are valied list entries themselves.

You can call it like this:

redisLPush("key", pi, 1, "cazart")

or more programatically via do.call:

do.call("redisLPush",args=list(key="key", pi,1,"cazart"))

igorper commented 10 years ago

Perfect!