Using Lua scripting, you can perform the following operations with 1
round trip using O(log n) time:
local result = redis.call('zrangebyscore', KEYS[1], ARGV[1], ARGV[1])
if #result > 0 then
return redis.call('zrank', KEYS[1], result[1])
endif
return -1
- Josiah
On Tue, Feb 26, 2013 at 2:22 PM, Chris Broglie <
cbro...@gmail.com> wrote:
> Based on the running time of ZCOUNT, this method would be O(n) where n is
> the number of elements in the set. Finding the rank of an arbitrary score
> should be able to be implemented in O(log(n)).
>
>
> On Tuesday, May 31, 2011 8:19:56 AM UTC-7, Karl Seguin wrote:
>>
>> duh, makes sense...at least it made for a fun evening!!
>>
>> Karl
>
> --
> You received this message because you are subscribed to the Google Groups
> "Redis DB" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to
redis-db+u...@googlegroups.com.
> Visit this group at
http://groups.google.com/group/redis-db?hl=en.
> For more options, visit
https://groups.google.com/groups/opt_out.
>
>