Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
SADDMULTI or similar - command to add a bunch of items to a set all at once
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  4 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Simon Willison  
View profile  
 More options Dec 12 2009, 6:27 pm
From: Simon Willison <si...@simonwillison.net>
Date: Sat, 12 Dec 2009 15:27:32 -0800 (PST)
Local: Sat, Dec 12 2009 6:27 pm
Subject: SADDMULTI or similar - command to add a bunch of items to a set all at once
I've been doing a bunch of works with sets recently (for
http://mps-expenses2.guardian.co.uk which primarily uses Redis for
random item selection with SRANDMEMBER). Currently, sets can be
composed either by multiple calls to SADD or using the extremely
useful SUNIONSTORE/SDIFFSTORE etc commands. The one case that isn't
covered is quickly building up a new set from scratch - that currently
takes multiple SADD commands.

Would it be appropriate for Redis to add a SADDMULTI command which can
take an arbitrary number of values and add them to a set all in one
atomic unit? It would have made a few tasks for the mps-expenses2
project more convenient. As it was, I had to build up temporary sets
and then RENAME them to ensure atomicity.

Cheers,

Simon


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Salvatore Sanfilippo  
View profile  
 More options Dec 12 2009, 6:33 pm
From: Salvatore Sanfilippo <anti...@gmail.com>
Date: Sun, 13 Dec 2009 00:33:30 +0100
Local: Sat, Dec 12 2009 6:33 pm
Subject: Re: SADDMULTI or similar - command to add a bunch of items to a set all at once
On Sun, Dec 13, 2009 at 12:27 AM, Simon Willison

<si...@simonwillison.net> wrote:
> Would it be appropriate for Redis to add a SADDMULTI command which can
> take an arbitrary number of values and add them to a set all in one
> atomic unit? It would have made a few tasks for the mps-expenses2
> project more convenient. As it was, I had to build up temporary sets
> and then RENAME them to ensure atomicity.

Hello Simon!

yes, it's planned, will probably be called MSADD, and will work in the
following way:

MSADD <num keys> <num values> <key1> <key2> ... <keyN> <val1> <val2> ... <valN>

So it will be a bit more general, for example allowing to add the same
two elements to multiple sets at once:

MSADD 3 2 set1 set2 set3 foo bar

Not sure if I can add this for 1.4, probably yes as it should not be
too complex to implement, but at the same time I need a refactoring of
the Sets code as I want to implement specialized sets representations
for sets composed of small (< signed 64bit) integers in a
memory-efficient way.

But at some time this command will surely get inside.

Cheers,
Salvatore

--
Salvatore 'antirez' Sanfilippo
http://invece.org

"Once you have something that grows faster than education grows,
you’re always going to get a pop culture.", Alan Kay


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Simon Willison  
View profile  
 More options Dec 12 2009, 6:51 pm
From: Simon Willison <si...@simonwillison.net>
Date: Sat, 12 Dec 2009 15:51:23 -0800 (PST)
Local: Sat, Dec 12 2009 6:51 pm
Subject: Re: SADDMULTI or similar - command to add a bunch of items to a set all at once
On Dec 12, 11:33 pm, Salvatore Sanfilippo <anti...@gmail.com> wrote:

> yes, it's planned, will probably be called MSADD, and will work in the
> following way:

> MSADD <num keys> <num values> <key1> <key2> ... <keyN> <val1> <val2> ... <valN>

> So it will be a bit more general, for example allowing to add the same
> two elements to multiple sets at once:

> MSADD 3 2 set1 set2 set3 foo bar

That's excellent - much more useful than what I was thinking about (I
can see how it would have helped with my most recent project). I
imagine the client libraries will hide the details of the API -
redis.msadd(['set1', 'set2', 'set3'], ['foo', 'bar']) for example.

Thanks,

Simon


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Salvatore Sanfilippo  
View profile  
 More options Dec 12 2009, 6:54 pm
From: Salvatore Sanfilippo <anti...@gmail.com>
Date: Sun, 13 Dec 2009 00:54:33 +0100
Local: Sat, Dec 12 2009 6:54 pm
Subject: Re: SADDMULTI or similar - command to add a bunch of items to a set all at once
On Sun, Dec 13, 2009 at 12:51 AM, Simon Willison

<si...@simonwillison.net> wrote:
> imagine the client libraries will hide the details of the API -
> redis.msadd(['set1', 'set2', 'set3'], ['foo', 'bar']) for example.

Yes, that's exactly my idea for the API. Also if the argument is not a
list but a string or symbol it should be considered like a
single-element list, so that this forms will work:

r.msadd('myset',['1','2','3'])
r.msadd(['set1','set2','set3'],"foo")

Cheers,
Salvatore

--
Salvatore 'antirez' Sanfilippo
http://invece.org

"Once you have something that grows faster than education grows,
you’re always going to get a pop culture.", Alan Kay


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »