Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How get last data from sorted set?

Tags:

redis

I saw a Redis tutorial. For my case there is a function: ZREVRANGEBYSCORE But I dont understand how get last one data via this function.

I tried ZREVRANGEBYSCORE myzset 0 1 for get last data row

like image 451
AhmedFaud Avatar asked Nov 11 '14 20:11

AhmedFaud


1 Answers

Assuming "last data" means the item with the largest score, use the ZREVRANGEBYSCORE command in the following manner:

ZREVRANGEBYSCORE <key> +inf -inf LIMIT 0 1
like image 151
Tim Cooper Avatar answered Oct 13 '22 23:10

Tim Cooper