@@ -10,7 +10,9 @@ class JSONCommands:
10
10
def arrappend (self , name , path = Path .rootPath (), * args ):
11
11
"""Append the objects ``args`` to the array under the
12
12
``path` in key ``name``.
13
- """
13
+
14
+ For more information: https://oss.redis.com/redisjson/commands/#jsonarrappend
15
+ """ # noqa
14
16
pieces = [name , str (path )]
15
17
for o in args :
16
18
pieces .append (self ._encode (o ))
@@ -23,7 +25,9 @@ def arrindex(self, name, path, scalar, start=0, stop=-1):
23
25
24
26
The search can be limited using the optional inclusive ``start``
25
27
and exclusive ``stop`` indices.
26
- """
28
+
29
+ For more information: https://oss.redis.com/redisjson/commands/#jsonarrindex
30
+ """ # noqa
27
31
return self .execute_command (
28
32
"JSON.ARRINDEX" , name , str (path ), self ._encode (scalar ),
29
33
start , stop
@@ -32,7 +36,9 @@ def arrindex(self, name, path, scalar, start=0, stop=-1):
32
36
def arrinsert (self , name , path , index , * args ):
33
37
"""Insert the objects ``args`` to the array at index ``index``
34
38
under the ``path` in key ``name``.
35
- """
39
+
40
+ For more information: https://oss.redis.com/redisjson/commands/#jsonarrinsert
41
+ """ # noqa
36
42
pieces = [name , str (path ), index ]
37
43
for o in args :
38
44
pieces .append (self ._encode (o ))
@@ -41,45 +47,64 @@ def arrinsert(self, name, path, index, *args):
41
47
def arrlen (self , name , path = Path .rootPath ()):
42
48
"""Return the length of the array JSON value under ``path``
43
49
at key``name``.
44
- """
50
+
51
+ For more information: https://oss.redis.com/redisjson/commands/#jsonarrlen
52
+ """ # noqa
45
53
return self .execute_command ("JSON.ARRLEN" , name , str (path ))
46
54
47
55
def arrpop (self , name , path = Path .rootPath (), index = - 1 ):
48
56
"""Pop the element at ``index`` in the array JSON value under
49
57
``path`` at key ``name``.
50
- """
58
+
59
+ For more information: https://oss.redis.com/redisjson/commands/#jsonarrpop
60
+ """ # noqa
51
61
return self .execute_command ("JSON.ARRPOP" , name , str (path ), index )
52
62
53
63
def arrtrim (self , name , path , start , stop ):
54
64
"""Trim the array JSON value under ``path`` at key ``name`` to the
55
65
inclusive range given by ``start`` and ``stop``.
56
- """
66
+
67
+ For more information: https://oss.redis.com/redisjson/commands/#jsonarrtrim
68
+ """ # noqa
57
69
return self .execute_command ("JSON.ARRTRIM" , name , str (path ),
58
70
start , stop )
59
71
60
72
def type (self , name , path = Path .rootPath ()):
61
- """Get the type of the JSON value under ``path`` from key ``name``."""
73
+ """Get the type of the JSON value under ``path`` from key ``name``.
74
+
75
+ For more information: https://oss.redis.com/redisjson/commands/#jsontype
76
+ """ # noqa
62
77
return self .execute_command ("JSON.TYPE" , name , str (path ))
63
78
64
79
def resp (self , name , path = Path .rootPath ()):
65
- """Return the JSON value under ``path`` at key ``name``."""
80
+ """Return the JSON value under ``path`` at key ``name``.
81
+
82
+ For more information: https://oss.redis.com/redisjson/commands/#jsonresp
83
+ """ # noqa
66
84
return self .execute_command ("JSON.RESP" , name , str (path ))
67
85
68
86
def objkeys (self , name , path = Path .rootPath ()):
69
87
"""Return the key names in the dictionary JSON value under ``path`` at
70
- key ``name``."""
88
+ key ``name``.
89
+
90
+ For more information: https://oss.redis.com/redisjson/commands/#jsonobjkeys
91
+ """ # noqa
71
92
return self .execute_command ("JSON.OBJKEYS" , name , str (path ))
72
93
73
94
def objlen (self , name , path = Path .rootPath ()):
74
95
"""Return the length of the dictionary JSON value under ``path`` at key
75
96
``name``.
76
- """
97
+
98
+ For more information: https://oss.redis.com/redisjson/commands/#jsonobjlen
99
+ """ # noqa
77
100
return self .execute_command ("JSON.OBJLEN" , name , str (path ))
78
101
79
102
def numincrby (self , name , path , number ):
80
103
"""Increment the numeric (integer or floating point) JSON value under
81
104
``path`` at key ``name`` by the provided ``number``.
82
- """
105
+
106
+ For more information: https://oss.redis.com/redisjson/commands/#jsonnumincrby
107
+ """ # noqa
83
108
return self .execute_command (
84
109
"JSON.NUMINCRBY" , name , str (path ), self ._encode (number )
85
110
)
@@ -88,7 +113,9 @@ def numincrby(self, name, path, number):
88
113
def nummultby (self , name , path , number ):
89
114
"""Multiply the numeric (integer or floating point) JSON value under
90
115
``path`` at key ``name`` with the provided ``number``.
91
- """
116
+
117
+ For more information: https://oss.redis.com/redisjson/commands/#jsonnummultby
118
+ """ # noqa
92
119
return self .execute_command (
93
120
"JSON.NUMMULTBY" , name , str (path ), self ._encode (number )
94
121
)
@@ -100,11 +127,16 @@ def clear(self, name, path=Path.rootPath()):
100
127
101
128
Return the count of cleared paths (ignoring non-array and non-objects
102
129
paths).
103
- """
130
+
131
+ For more information: https://oss.redis.com/redisjson/commands/#jsonclear
132
+ """ # noqa
104
133
return self .execute_command ("JSON.CLEAR" , name , str (path ))
105
134
106
135
def delete (self , key , path = Path .rootPath ()):
107
- """Delete the JSON value stored at key ``key`` under ``path``."""
136
+ """Delete the JSON value stored at key ``key`` under ``path``.
137
+
138
+ For more information: https://oss.redis.com/redisjson/commands/#jsondel
139
+ """
108
140
return self .execute_command ("JSON.DEL" , key , str (path ))
109
141
110
142
# forget is an alias for delete
@@ -117,7 +149,9 @@ def get(self, name, *args, no_escape=False):
117
149
``args`` is zero or more paths, and defaults to root path
118
150
```no_escape`` is a boolean flag to add no_escape option to get
119
151
non-ascii characters
120
- """
152
+
153
+ For more information: https://oss.redis.com/redisjson/commands/#jsonget
154
+ """ # noqa
121
155
pieces = [name ]
122
156
if no_escape :
123
157
pieces .append ("noescape" )
@@ -140,7 +174,9 @@ def mget(self, keys, path):
140
174
"""
141
175
Get the objects stored as a JSON values under ``path``. ``keys``
142
176
is a list of one or more keys.
143
- """
177
+
178
+ For more information: https://oss.redis.com/redisjson/commands/#jsonmget
179
+ """ # noqa
144
180
pieces = []
145
181
pieces += keys
146
182
pieces .append (str (path ))
@@ -157,6 +193,8 @@ def set(self, name, path, obj, nx=False, xx=False, decode_keys=False):
157
193
158
194
For the purpose of using this within a pipeline, this command is also
159
195
aliased to jsonset.
196
+
197
+ For more information: https://oss.redis.com/redisjson/commands/#jsonset
160
198
"""
161
199
if decode_keys :
162
200
obj = decode_dict_keys (obj )
@@ -178,7 +216,9 @@ def set(self, name, path, obj, nx=False, xx=False, decode_keys=False):
178
216
def strlen (self , name , path = None ):
179
217
"""Return the length of the string JSON value under ``path`` at key
180
218
``name``.
181
- """
219
+
220
+ For more information: https://oss.redis.com/redisjson/commands/#jsonstrlen
221
+ """ # noqa
182
222
pieces = [name ]
183
223
if path is not None :
184
224
pieces .append (str (path ))
@@ -187,14 +227,18 @@ def strlen(self, name, path=None):
187
227
def toggle (self , name , path = Path .rootPath ()):
188
228
"""Toggle boolean value under ``path`` at key ``name``.
189
229
returning the new value.
190
- """
230
+
231
+ For more information: https://oss.redis.com/redisjson/commands/#jsontoggle
232
+ """ # noqa
191
233
return self .execute_command ("JSON.TOGGLE" , name , str (path ))
192
234
193
235
def strappend (self , name , value , path = Path .rootPath ()):
194
236
"""Append to the string JSON value. If two options are specified after
195
237
the key name, the path is determined to be the first. If a single
196
238
option is passed, then the rootpath (i.e Path.rootPath()) is used.
197
- """
239
+
240
+ For more information: https://oss.redis.com/redisjson/commands/#jsonstrappend
241
+ """ # noqa
198
242
pieces = [name , str (path ), self ._encode (value )]
199
243
return self .execute_command (
200
244
"JSON.STRAPPEND" , * pieces
@@ -203,7 +247,9 @@ def strappend(self, name, value, path=Path.rootPath()):
203
247
def debug (self , subcommand , key = None , path = Path .rootPath ()):
204
248
"""Return the memory usage in bytes of a value under ``path`` from
205
249
key ``name``.
206
- """
250
+
251
+ For more information: https://oss.redis.com/redisjson/commands/#jsondebg
252
+ """ # noqa
207
253
valid_subcommands = ["MEMORY" , "HELP" ]
208
254
if subcommand not in valid_subcommands :
209
255
raise DataError ("The only valid subcommands are " ,
0 commit comments