@@ -2536,9 +2536,14 @@ def zrevrange(self, name, start, end, withscores=False,
2536
2536
2537
2537
``score_cast_func`` a callable used to cast the score return value
2538
2538
"""
2539
- return self .zrange (name , start , end , desc = True ,
2540
- withscores = withscores ,
2541
- score_cast_func = score_cast_func )
2539
+ pieces = ['ZREVRANGE' , name , start , end ]
2540
+ if withscores :
2541
+ pieces .append (b'WITHSCORES' )
2542
+ options = {
2543
+ 'withscores' : withscores ,
2544
+ 'score_cast_func' : score_cast_func
2545
+ }
2546
+ return self .execute_command (* pieces , ** options )
2542
2547
2543
2548
def zrangestore (self , dest , name , start , end ,
2544
2549
byscore = False , bylex = False , desc = False ,
@@ -2575,7 +2580,13 @@ def zrangebylex(self, name, min, max, start=None, num=None):
2575
2580
If ``start`` and ``num`` are specified, then return a slice of the
2576
2581
range.
2577
2582
"""
2578
- return self .zrange (name , min , max , bylex = True , offset = start , num = num )
2583
+ if (start is not None and num is None ) or \
2584
+ (num is not None and start is None ):
2585
+ raise DataError ("``start`` and ``num`` must both be specified" )
2586
+ pieces = ['ZRANGEBYLEX' , name , min , max ]
2587
+ if start is not None and num is not None :
2588
+ pieces .extend ([b'LIMIT' , start , num ])
2589
+ return self .execute_command (* pieces )
2579
2590
2580
2591
def zrevrangebylex (self , name , max , min , start = None , num = None ):
2581
2592
"""
@@ -2585,8 +2596,13 @@ def zrevrangebylex(self, name, max, min, start=None, num=None):
2585
2596
If ``start`` and ``num`` are specified, then return a slice of the
2586
2597
range.
2587
2598
"""
2588
- return self .zrange (name , max , min , desc = True ,
2589
- bylex = True , offset = start , num = num )
2599
+ if (start is not None and num is None ) or \
2600
+ (num is not None and start is None ):
2601
+ raise DataError ("``start`` and ``num`` must both be specified" )
2602
+ pieces = ['ZREVRANGEBYLEX' , name , max , min ]
2603
+ if start is not None and num is not None :
2604
+ pieces .extend (['LIMIT' , start , num ])
2605
+ return self .execute_command (* pieces )
2590
2606
2591
2607
def zrangebyscore (self , name , min , max , start = None , num = None ,
2592
2608
withscores = False , score_cast_func = float ):
@@ -2602,10 +2618,19 @@ def zrangebyscore(self, name, min, max, start=None, num=None,
2602
2618
2603
2619
`score_cast_func`` a callable used to cast the score return value
2604
2620
"""
2605
- return self .zrange (name , min , max , byscore = True ,
2606
- offset = start , num = num ,
2607
- withscores = withscores ,
2608
- score_cast_func = score_cast_func )
2621
+ if (start is not None and num is None ) or \
2622
+ (num is not None and start is None ):
2623
+ raise DataError ("``start`` and ``num`` must both be specified" )
2624
+ pieces = ['ZRANGEBYSCORE' , name , min , max ]
2625
+ if start is not None and num is not None :
2626
+ pieces .extend (['LIMIT' , start , num ])
2627
+ if withscores :
2628
+ pieces .append ('WITHSCORES' )
2629
+ options = {
2630
+ 'withscores' : withscores ,
2631
+ 'score_cast_func' : score_cast_func
2632
+ }
2633
+ return self .execute_command (* pieces , ** options )
2609
2634
2610
2635
def zrevrangebyscore (self , name , max , min , start = None , num = None ,
2611
2636
withscores = False , score_cast_func = float ):
@@ -2621,10 +2646,19 @@ def zrevrangebyscore(self, name, max, min, start=None, num=None,
2621
2646
2622
2647
``score_cast_func`` a callable used to cast the score return value
2623
2648
"""
2624
- return self .zrange (name , max , min , desc = True ,
2625
- byscore = True , offset = start ,
2626
- num = num , withscores = withscores ,
2627
- score_cast_func = score_cast_func )
2649
+ if (start is not None and num is None ) or \
2650
+ (num is not None and start is None ):
2651
+ raise DataError ("``start`` and ``num`` must both be specified" )
2652
+ pieces = ['ZREVRANGEBYSCORE' , name , max , min ]
2653
+ if start is not None and num is not None :
2654
+ pieces .extend (['LIMIT' , start , num ])
2655
+ if withscores :
2656
+ pieces .append ('WITHSCORES' )
2657
+ options = {
2658
+ 'withscores' : withscores ,
2659
+ 'score_cast_func' : score_cast_func
2660
+ }
2661
+ return self .execute_command (* pieces , ** options )
2628
2662
2629
2663
def zrank (self , name , value ):
2630
2664
"""
0 commit comments