@@ -55,10 +55,6 @@ func (server *EchoVault) LLen(key string) (int, error) {
55
55
// Errors:
56
56
//
57
57
// "LRange command on non-list item" - when the provided key exists but is not a list.
58
- //
59
- // "start index must be within list boundary" - when the start index is not within the list boundaries.
60
- //
61
- // "end index must be within list range or -1" - when end index is not within the list boundaries.
62
58
func (server * EchoVault ) LRange (key string , start , end int ) ([]string , error ) {
63
59
b , err := server .handleCommand (server .context , internal .EncodeCommand ([]string {"LRANGE" , key , strconv .Itoa (start ), strconv .Itoa (end )}), nil , false , true )
64
60
if err != nil {
@@ -80,8 +76,6 @@ func (server *EchoVault) LRange(key string, start, end int) ([]string, error) {
80
76
// Errors:
81
77
//
82
78
// "LIndex command on non-list item" - when the provided key exists but is not a list.
83
- //
84
- // "index must be within list range" - when the index is not within the list boundary.
85
79
func (server * EchoVault ) LIndex (key string , index uint ) (string , error ) {
86
80
b , err := server .handleCommand (server .context , internal .EncodeCommand ([]string {"LINDEX" , key , strconv .Itoa (int (index ))}), nil , false , true )
87
81
if err != nil {
@@ -139,23 +133,22 @@ func (server *EchoVault) LTrim(key string, start int, end int) (bool, error) {
139
133
//
140
134
// `value` - string - the element to remove.
141
135
//
142
- // Returns: true if the removal was successful .
136
+ // Returns: An integer representing the number of elements removed .
143
137
//
144
138
// Errors:
145
139
//
146
140
// "LRem command on non-list item" - when the provided key exists but is not a list.
147
- func (server * EchoVault ) LRem (key string , count int , value string ) (bool , error ) {
141
+ func (server * EchoVault ) LRem (key string , count int , value string ) (int , error ) {
148
142
b , err := server .handleCommand (server .context , internal .EncodeCommand ([]string {
149
143
"LREM" , key , strconv .Itoa (count ), value }),
150
144
nil ,
151
145
false ,
152
146
true ,
153
147
)
154
148
if err != nil {
155
- return false , err
149
+ return 0 , err
156
150
}
157
- s , err := internal .ParseStringResponse (b )
158
- return strings .EqualFold (s , "ok" ), err
151
+ return internal .ParseIntegerResponse (b )
159
152
}
160
153
161
154
// LMove moves an element from one list to another.
@@ -194,17 +187,23 @@ func (server *EchoVault) LMove(source, destination, whereFrom, whereTo string) (
194
187
//
195
188
// `key` - string - the key to the list.
196
189
//
197
- // Returns: The popped element as a string .
190
+ // Returns: A string slice containing the popped elements .
198
191
//
199
192
// Errors:
200
193
//
201
- // "LPop command on non-list item" - when the provided key is not a list.
202
- func (server * EchoVault ) LPop (key string ) (string , error ) {
203
- b , err := server .handleCommand (server .context , internal .EncodeCommand ([]string {"LPOP" , key }), nil , false , true )
194
+ // "LPOP command on non-list item" - when the provided key is not a list.
195
+ func (server * EchoVault ) LPop (key string , count uint ) ([]string , error ) {
196
+ b , err := server .handleCommand (
197
+ server .context ,
198
+ internal .EncodeCommand ([]string {"LPOP" , key , strconv .Itoa (int (count ))}),
199
+ nil ,
200
+ false ,
201
+ true ,
202
+ )
204
203
if err != nil {
205
- return "" , err
204
+ return [] string {} , err
206
205
}
207
- return internal .ParseStringResponse (b )
206
+ return internal .ParseStringArrayResponse (b )
208
207
}
209
208
210
209
// RPop pops an element from the end of the list and return it.
@@ -213,17 +212,23 @@ func (server *EchoVault) LPop(key string) (string, error) {
213
212
//
214
213
// `key` - string - the key to the list.
215
214
//
216
- // Returns: The popped element as a string .
215
+ // Returns: A string slice containing the popped elements .
217
216
//
218
217
// Errors:
219
218
//
220
- // "RPop command on non-list item" - when the provided key is not a list.
221
- func (server * EchoVault ) RPop (key string ) (string , error ) {
222
- b , err := server .handleCommand (server .context , internal .EncodeCommand ([]string {"RPOP" , key }), nil , false , true )
219
+ // "RPOP command on non-list item" - when the provided key is not a list.
220
+ func (server * EchoVault ) RPop (key string , count uint ) ([]string , error ) {
221
+ b , err := server .handleCommand (
222
+ server .context ,
223
+ internal .EncodeCommand ([]string {"RPOP" , key , strconv .Itoa (int (count ))}),
224
+ nil ,
225
+ false ,
226
+ true ,
227
+ )
223
228
if err != nil {
224
- return "" , err
229
+ return [] string {} , err
225
230
}
226
- return internal .ParseStringResponse (b )
231
+ return internal .ParseStringArrayResponse (b )
227
232
}
228
233
229
234
// LPush pushed 1 or more values to the beginning of a list. If the list does not exist, a new list is created
0 commit comments