@@ -51,11 +51,13 @@ def __init__(self, encoder=None, decoder=None, *args, **kwargs):
51
51
# Set the module commands' callbacks
52
52
MODULE_CALLBACKS = {
53
53
'JSON.DEL' : long ,
54
+ 'JSON.CLEAR' : long ,
54
55
'JSON.GET' : self ._decode ,
55
56
'JSON.MGET' : bulk_of_jsons (self ._decode ),
56
57
'JSON.SET' : lambda r : r and nativestr (r ) == 'OK' ,
57
58
'JSON.NUMINCRBY' : self ._decode ,
58
59
'JSON.NUMMULTBY' : self ._decode ,
60
+ 'JSON.TOGGLE' : lambda b : b == 'true' ,
59
61
'JSON.STRAPPEND' : long ,
60
62
'JSON.STRLEN' : long ,
61
63
'JSON.ARRAPPEND' : long ,
@@ -65,10 +67,11 @@ def __init__(self, encoder=None, decoder=None, *args, **kwargs):
65
67
'JSON.ARRPOP' : self ._decode ,
66
68
'JSON.ARRTRIM' : long ,
67
69
'JSON.OBJLEN' : long ,
70
+ 'JSON.DEBUG' : long ,
68
71
}
69
72
for k , v in six .iteritems (MODULE_CALLBACKS ):
70
73
self .set_response_callback (k , v )
71
-
74
+
72
75
def setEncoder (self , encoder ):
73
76
"""
74
77
Sets the client's encoder
@@ -99,6 +102,14 @@ def jsondel(self, name, path=Path.rootPath()):
99
102
"""
100
103
return self .execute_command ('JSON.DEL' , name , str_path (path ))
101
104
105
+ def jsonclear (self , name , path = Path .rootPath ()):
106
+ """
107
+ Emptying arrays and objects (to have zero slots/keys without
108
+ deleting the array/object) returning the count of cleared paths
109
+ (ignoring non-array and non-objects paths)
110
+ """
111
+ return self .execute_command ('JSON.CLEAR' , name , str_path (path ))
112
+
102
113
def jsonget (self , name , * args , no_escape = False ):
103
114
"""
104
115
Get the object stored as a JSON value at key ``name``
@@ -166,6 +177,13 @@ def jsonnummultby(self, name, path, number):
166
177
"""
167
178
return self .execute_command ('JSON.NUMMULTBY' , name , str_path (path ), self ._encode (number ))
168
179
180
+ def jsontoggle (self , name , path = Path .rootPath ()):
181
+ """
182
+ Toggle boolean value under ``path`` at key ``name``,
183
+ Returning the new value.
184
+ """
185
+ return self .execute_command ('JSON.TOGGLE' , name , str_path (path ))
186
+
169
187
def jsonstrappend (self , name , string , path = Path .rootPath ()):
170
188
"""
171
189
Appends to the string JSON value under ``path`` at key ``name`` the
@@ -243,6 +261,12 @@ def jsonobjlen(self, name, path=Path.rootPath()):
243
261
"""
244
262
return self .execute_command ('JSON.OBJLEN' , name , str_path (path ))
245
263
264
+ def jsondebugmemory (self , name , path = Path .rootPath ()):
265
+ """
266
+ Returns the memory usage in bytes of a value under ``path`` from key ``name``.
267
+ """
268
+ return self .execute_command ("JSON.DEBUG" , "MEMORY" , name , str_path (path ))
269
+
246
270
def pipeline (self , transaction = True , shard_hint = None ):
247
271
"""
248
272
Return a new pipeline object that can queue multiple commands for
0 commit comments