Reputation: 4872
I would like to do an aggregate function on Redis that is time/timestamp-based.
Right now I am storing count of the events per key and a timestamp. I would like to do an aggregation to pull how many counts have been incurred in particular time interval (e.g. in moths of June and July).
With SQL this would be something like:
select count(*) from events
where event_timestamp BETWEEN '2013-06-01 23:55:00'::timestamp
AND '2013-07-31 23:55:00'::timestamp;
What would be the way to do this in Redis, if possible?
Upvotes: 0
Views: 1099
Reputation: 1176
Consider using zadd, zrange queries in redis :
ZADD events event_1 "timestamp1"
ZADD events event_1 "timestamp2"
Query them as:
zrange events "timestamp1" "timestamp2"
Upvotes: 1