Issue 419 in redis: Increment element in a list: LINCRBY command

287 views
Skip to first unread message

re...@googlecode.com

unread,
Dec 27, 2010, 12:28:46 PM12/27/10
to redi...@googlegroups.com
Status: New
Owner: ----
Labels: Type-Defect Priority-Medium

New issue 419 by gimenete: Increment element in a list: LINCRBY command
http://code.google.com/p/redis/issues/detail?id=419

This is a feature request.

A command similar to "HINCRBY key field increment" but for lists.

Suggestion:
LINCRBY key index increment

re...@googlecode.com

unread,
Dec 28, 2010, 12:22:54 AM12/28/10
to redi...@googlegroups.com

Comment #1 on issue 419 by cd-s...@mail.ru: Increment element in a list:
LINCRBY command
http://code.google.com/p/redis/issues/detail?id=419

i gues u dont have POS of element u would incr/decr +/- N
so... its a bit difficult? ;)

re...@googlecode.com

unread,
Dec 28, 2010, 2:18:59 AM12/28/10
to redi...@googlegroups.com
Updates:
Status: WontFix
Labels: -Type-Defect Type-Enhancement

Comment #2 on issue 419 by pcnoordhuis: Increment element in a list:
LINCRBY command
http://code.google.com/p/redis/issues/detail?id=419

This would only make sense for static lists, which is an uncommon use case
for Redis lists. Lists are more often used for rapidly changing contents.
You need to know in advance which element the INCR is done on, which is
hard to tell without first pulling a few values from the list when the
contents changes. Doing exactly this is already possible in Redis using
optimistic locking with WATCH:

WATCH list
value = LINDEX list 9 # Returns 10th element
if value == what_you_expect
MULTI
LSET list 9 value+1
EXEC
else
UNWATCH
end

If the indices of a list are static and you know in advance how many
elements you store inside that list, you can also choose to use the hash
type for storing this "list". Because you know it is static, the element
indices are the implicit ordering, so you can use an unordered type to
simulate a (static) list:

HSET hash 0 value1 # Index 0
HSET hash 1 value2 # Index 1
HINCRBY hash 0 1 # Increment element at key "0" (which in this case is
your index)

Because there already are ways in Redis to solve this, I'm closing this
feature request.

re...@googlecode.com

unread,
Dec 28, 2010, 4:07:44 AM12/28/10
to redi...@googlegroups.com

Comment #3 on issue 419 by gimenete: Increment element in a list: LINCRBY
command
http://code.google.com/p/redis/issues/detail?id=419

Hi,

I think the use of static lists can be very common. For example I need to
handle calendars. A calendar is a fixed-length number of days. Almost
anything in the application I'm building are calendars, because what I need
is to track statistics in time.

Thanks anyway. You are doing a great work.

Reply all
Reply to author
Forward
0 new messages