djveremix / redis

Automatically exported from code.google.com/p/redis
0 stars 0 forks source link

Feature request: ZRANGE key start end WITHRANKS #228

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
In addition to WITHSCORES, it would be very helpful to have a WITHRANKS option 
for the Z* 
commands.

If WITHRANKS is specified, then an additional field is provided showing the 
rank, similar to how 
WITHSCORES works:

   ZRANGE top_players 0 4 WITHRANKS
   ['Nate', 0, 'Pete', 1, 'Jeff', 2, 'James', 3, 'Matt', 4]

If both WITHSCORES and WITHRANKS are provided, then the ranks should come last, 
to keep API 
compatibility:

   ZRANGE top_players 0 4 WITHSCORES WITHRANKS
   ['Nate', 145, 0, 'Pete', 156, 1, 'Jeff', 198, 2, 'James', 221, 3, 'Matt', 255, 4]

While you can reconstruct the rank client side by iterating through the data 
and doing an i++ or 
equivalent, this requires an extra step, and Redis already has this information 
available.

Original issue reported on code.google.com by nwi...@gmail.com on 16 Apr 2010 at 6:41

GoogleCodeExporter commented 9 years ago
Sorry I can't understand how this can be useful. Why transfer more data if you 
can increment a variable?

Original comment by anti...@gmail.com on 26 Apr 2010 at 6:35

GoogleCodeExporter commented 9 years ago

Original comment by anti...@gmail.com on 27 Aug 2010 at 11:10