for example, using the ruby client:
redis.pipeline do
redis.hincrby 'foo', 'a'
redis.hincrby 'foo', 'b'
...
end
cheers
tim
On 2010-09-15, at 12:00 , dvirsky wrote:
> I'm using redis (among other things) for a text classifier, where each
> word has a hash containing a count of its appearance in different
> categories. This means that training the classifier with a document of
> 1000 words, I need to make at least 1000 HINCRBY queries. which is
> (relatively) slow.
--
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.
Because you don't have MINCRBY?
Hello Dvir, unfortunately there is some place where we need to stop
the specialization of commands.
And MSET is a very general operation of "set M values", so it seemed
like an important one to have, one of the most importants actually.
The same as DEL that is variadic.
Most other operations make sense in the "M" variant, but we found the
performances with pipelining are very close. We think we are currently
better serving the community with a shorter list of commands than with
slightly better performances for multi-operations compared to what you
get with pipelining.
Cheers,
Salvatore
--
Salvatore 'antirez' Sanfilippo
http://invece.org
"We are what we repeatedly do. Excellence, therefore, is not an act,
but a habit." -- Aristotele
--
Hey Dvir,
for floats you have currently two options.
Option 1: use ZINCRBY to increment and ZSCORE to get the value,
against a sorted set of course.
Option 2: take your float, multiply it by... 100 for instance (if you
are ok with three digits after the dot), floor() it, add it. Do the
reverse when you want to retrieve the score.
Redis supports integers up to 64 bit in both 32 and 64 bit instances.
Cheers,
Salvatore
Ok with this you have a range of:
+/- 922337203685477
still much better than a 32 bit, and hard to overflow in a reasonable time.
for instance with 1 million increments every second you need 30 years
to overflow :)
And this gives you three digits of precision after the dot.
Sounds cool :)
But note that there is another interestion option that I forgot to
mention, that is to use two keys: one for the integer part and one for
the comma. Wrapping both increments and readings of the value in
MULTI/EXEC. Can be useful when there is the need of greater precision,
but there is to handle overflow (still possible in a completely atomic
way).
Cheers,
Salvatore