Most efficient way to pop atomically lots of list items

10 views
Skip to first unread message

Pavel Shevaev

unread,
Jun 13, 2011, 7:31:38 AM6/13/11
to redi...@googlegroups.com
Hi!

What is the most efficient way to pop atomically a large amount of
items from a list?

I'm thinking of usage of the following set of commands:

MULTI
LRANGE foo X Y
LTRIM foo X Y
EXEC

What do you think?

P.S. Wouldn't it be nice to have an optional argument for LTRIM which
would make it return the trimmed stuff?

--
Best regards, Pavel

Josiah Carlson

unread,
Jun 15, 2011, 5:11:27 PM6/15/11
to redi...@googlegroups.com
On Mon, Jun 13, 2011 at 4:31 AM, Pavel Shevaev <pacha....@gmail.com> wrote:
> Hi!
>
> What is the most efficient way to pop atomically a large amount of
> items from a list?
>
> I'm thinking of usage of the following set of commands:
>
> MULTI
> LRANGE foo X Y
> LTRIM foo X Y
> EXEC
>
> What do you think?

That is the right way.

> P.S. Wouldn't it be nice to have an optional argument for LTRIM which
> would make it return the trimmed stuff?

Sure, but then there would be 2 ways to do the exact same thing that
is easily performed with the existing commands.

- Josiah

Pavel Shevaev

unread,
Jun 16, 2011, 1:54:06 PM6/16/11
to redi...@googlegroups.com
>> MULTI
>> LRANGE foo X Y
>> LTRIM foo X Y
>> EXEC
>>
>> What do you think?
>
> That is the right way.

Thanks.

--
Best regards, Pavel

Reply all
Reply to author
Forward
0 new messages