jlb333333
jlb333333

Reputation: 371

Adding up values(aggregating) with Redis

Using the latest Redis, is there a way to aggregate values with Redis.

Eg.

set (or hset or sadd) a 3.55
set b 7.66
set c 13.32
etc.

How do I get a + b + c?

I have searched online everywhere.

I have no idea how to do this.

If I can't do it (easily) Redis is the wrong place for me to do what I am trying to do.

Many thanks.

Upvotes: 1

Views: 778

Answers (1)

Itamar Haber
Itamar Haber

Reputation: 49962

No - this isn't a part of Redis at the moment.

For ad-hoc aggregates you should use a Lua script for that - see the EVAL command - or bring the data to the application and aggregate it there.

If you know what your aggregates need to be, an alternative is just to keep them updated with the rest of the data (i.e. with every write operation).

Upvotes: 2

Related Questions