@@ -12,27 +12,6 @@ def str_path(p):
12
12
else :
13
13
return p
14
14
15
- def float_or_long (n ):
16
- "Return a number from a Redis reply"
17
- if isinstance (n , six .string_types ):
18
- return float (n )
19
- else :
20
- return long (n )
21
-
22
- def long_or_none (r ):
23
- "Return a long or None from a Redis reply"
24
- if r :
25
- return long (r )
26
- return r
27
-
28
- def json_or_none (d ):
29
- "Return a deserialized JSON object or None"
30
- def _f (r ):
31
- if r :
32
- return d (r )
33
- return r
34
- return _f
35
-
36
15
def bulk_of_jsons (d ):
37
16
"Replace serialized JSON values with objects in a bulk array response (list)"
38
17
def _f (b ):
@@ -75,20 +54,20 @@ def __init__(self, encoder=None, decoder=None, *args, **kwargs):
75
54
# Set the module commands' callbacks
76
55
MODULE_CALLBACKS = {
77
56
'JSON.DEL' : long ,
78
- 'JSON.GET' : json_or_none ( self ._decode ) ,
57
+ 'JSON.GET' : self ._decode ,
79
58
'JSON.MGET' : bulk_of_jsons (self ._decode ),
80
59
'JSON.SET' : lambda r : r and nativestr (r ) == 'OK' ,
81
- 'JSON.NUMINCRBY' : float_or_long ,
82
- 'JSON.NUMMULTBY' : float_or_long ,
83
- 'JSON.STRAPPEND' : long_or_none ,
84
- 'JSON.STRLEN' : long_or_none ,
85
- 'JSON.ARRAPPEND' : long_or_none ,
86
- 'JSON.ARRINDEX' : long_or_none ,
87
- 'JSON.ARRINSERT' : long_or_none ,
88
- 'JSON.ARRLEN' : long_or_none ,
89
- 'JSON.ARRPOP' : json_or_none ( self ._decode ) ,
90
- 'JSON.ARRTRIM' : long_or_none ,
91
- 'JSON.OBJLEN' : long_or_none ,
60
+ 'JSON.NUMINCRBY' : self . _decode ,
61
+ 'JSON.NUMMULTBY' : self . _decode ,
62
+ 'JSON.STRAPPEND' : long ,
63
+ 'JSON.STRLEN' : long ,
64
+ 'JSON.ARRAPPEND' : long ,
65
+ 'JSON.ARRINDEX' : long ,
66
+ 'JSON.ARRINSERT' : long ,
67
+ 'JSON.ARRLEN' : long ,
68
+ 'JSON.ARRPOP' : self ._decode ,
69
+ 'JSON.ARRTRIM' : long ,
70
+ 'JSON.OBJLEN' : long ,
92
71
}
93
72
for k , v in six .iteritems (MODULE_CALLBACKS ):
94
73
self .set_response_callback (k , v )
0 commit comments