zrangebyscore redis in perl -
i'm using redis.pm in perl scrpit , try execute next command:
zrevrangebyscore <key> <highscore> 0 withscores limit 0 1
in appliance redis documentation write next , it's working fine
my $data = { $redis->zrevrangebyscore($rkey, $ipl, 0, 'withscores') };
but when try subst 'limit...' in perl command:
my $data = { $redis->zrevrangebyscore($rkey, $ipl, 0, 'withscores','limit 0 1') };
i got error
[zrevrangebyscore] err syntax error, @ /usr/local/lib/perl5/site_perl/5.14/redis.pm line 163 redis::__anon__(undef, 'err syntax error') called @ /usr/local/lib/perl5/site_perl/5.14/redis.pm line 195 redis::wait_one_response('redis=hash(0x801075300)') called @ /usr/local/lib/perl5/site_perl/5.14/redis.pm line 183 redis::wait_all_responses('redis=hash(0x801075300)') called @ /usr/local/lib/perl5/site_perl/5.14/redis.pm line 172
how can pass arg 'limit 0 1' in redis.pm ?
if looking iterate through sorted set, , fetch highest entry, use
zrange
instead of zrevrangebyscore.
my $start = -1; #-1 last element = element highest score $stop = -1; while (my $data = $redis->zrange($rkey, $start--, $stop--, 'withscores')) { #fetch ultimate element, penultimate, etc.... };
Comments
Post a Comment