HDECRBY?

517 views
Skip to first unread message

zzz

unread,
Oct 14, 2011, 6:18:37 PM10/14/11
to Redis DB
Why isn't there a HDECRBY command?

I have a typically use case of an object that contains 8 numbers, and
4 of them are going to be frequently decremented. An atomic HDECRBY
(similar to DECRBY) would be perfect. Is there any reason that this
command isn't there?

How would you do it with the existing command atomically?

Thanks.

Andy McCurdy

unread,
Oct 14, 2011, 6:20:55 PM10/14/11
to redi...@googlegroups.com
You can pass negative values to HINCRBY.


--
You received this message because you are subscribed to the Google Groups "Redis DB" group.
To post to this group, send email to redi...@googlegroups.com.
To unsubscribe from this group, send email to redis-db+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/redis-db?hl=en.


Chad Zou

unread,
Oct 15, 2011, 6:53:06 PM10/15/11
to redi...@googlegroups.com
is HINCRBY atomic? the documentation is unclear

Dvir Volk

unread,
Oct 15, 2011, 7:10:01 PM10/15/11
to redi...@googlegroups.com
yes it is. since redis is single threaded, virtually all single commands are atomic.
Dvir Volk
System Architect, DoAT, http://doat.com

Josiah Carlson

unread,
Oct 15, 2011, 7:15:13 PM10/15/11
to redi...@googlegroups.com
Correction: all single commands are atomic.

As are all commands performed between a MULTI/EXEC.

- Josiah

Dvir Volk

unread,
Oct 15, 2011, 7:17:09 PM10/15/11
to redi...@googlegroups.com
you could argue that bgsave is not.. :)

Joe Allen

unread,
Oct 15, 2011, 8:23:33 PM10/15/11
to redi...@googlegroups.com

HINCRBY using a negative number will do the trick.

Josiah Carlson

unread,
Oct 15, 2011, 10:14:34 PM10/15/11
to redi...@googlegroups.com
It surely is atomic. Once that bgsave command is executed, nothing
done in Redis can materially affect the dump unless the forked process
dies without writing the file.

Regards,
- Josiah

Dvir Volk

unread,
Oct 16, 2011, 3:35:20 AM10/16/11
to redi...@googlegroups.com
yeah I know, it was only a joke dude :)
Reply all
Reply to author
Forward
0 new messages