I would like to be able to do intersections on sets and a score- or
rank-limited sorted sets.
Assume that we have some sorted sets:
* users:activity {timestamp, userid}
* users:age {age, userid}
And some sets
* users:male {userid}
It would be nice to be able to do something like (syntax not supposed to be
redis):
users:activity by rank 0 to 100 INTERSECT users:age by score <18> to +inf INTERSECT users:male
Not sure how this could be expressed without changing the current syntax too
much, perhaps using an extension to ZRANGE a la:
ZSTORERANGE dstkey key start end #Store a sorted set range (by rank) as a set
ZSTORERANGEBYSCORE dstkey key min max #Store a sorted set range (by score) as a set
That would mean that I could do my intersection as:
INCR i
ZSTORERANGE tmp:<i>:activity users:activity 0 100
ZSTORERANGEBYSCORE tmp:<i>:age users:age 18 +inf
SINTER tmp:<i>:activity tmp:<i>:age users:male
DEL tmp:<i>:activity
DEL tmp:<i>:age
I realize that this requires a few calls to redis; but I thinks it is
preferable to having to transport the sets back and forth to do the
intersection.
What do you think?
- Jake
Original issue reported on code.google.com by jacob.ba...@gmail.com on 16 Aug 2010 at 10:17
Original issue reported on code.google.com by
jacob.ba...@gmail.com
on 16 Aug 2010 at 10:17