Skip to content

Commit fb16102

Browse files
committed
Rename ELF.convertFromRESPValue to be an overload of map
1 parent 6bd5df7 commit fb16102

7 files changed

+67
-67
lines changed

Sources/RediStack/Commands/BasicCommands.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ extension RedisClient {
2424
public func echo(_ message: String) -> EventLoopFuture<String> {
2525
let args = [RESPValue(bulk: message)]
2626
return send(command: "ECHO", with: args)
27-
.convertFromRESPValue()
27+
.map()
2828
}
2929

3030
/// Pings the server, which will respond with a message.
@@ -38,7 +38,7 @@ extension RedisClient {
3838
? [.init(bulk: message!)] // safe because we did a nil pre-check
3939
: []
4040
return send(command: "PING", with: args)
41-
.convertFromRESPValue()
41+
.map()
4242
}
4343

4444
/// Select the Redis logical database having the specified zero-based numeric index.
@@ -68,7 +68,7 @@ extension RedisClient {
6868
.init(bulk: second)
6969
]
7070
return send(command: "SWAPDB", with: args)
71-
.convertFromRESPValue(to: String.self)
71+
.map(to: String.self)
7272
.map { return $0 == "OK" }
7373
}
7474

@@ -95,7 +95,7 @@ extension RedisClient {
9595

9696
let args = keys.map(RESPValue.init)
9797
return send(command: "DEL", with: args)
98-
.convertFromRESPValue()
98+
.map()
9999
}
100100

101101
/// Removes the specified keys. A key is ignored if it does not exist.
@@ -123,7 +123,7 @@ extension RedisClient {
123123
.init(bulk: timeout.seconds)
124124
]
125125
return send(command: "EXPIRE", with: args)
126-
.convertFromRESPValue(to: Int.self)
126+
.map(to: Int.self)
127127
.map { return $0 == 1 }
128128
}
129129
}
@@ -175,7 +175,7 @@ extension RedisClient {
175175
args.append(.init(bulk: c))
176176
}
177177

178-
let response = send(command: command, with: args).convertFromRESPValue(to: [RESPValue].self)
178+
let response = send(command: command, with: args).map(to: [RESPValue].self)
179179
let position = response.flatMapThrowing { result -> Int in
180180
guard
181181
let value = result[0].string,
@@ -187,7 +187,7 @@ extension RedisClient {
187187
}
188188
let elements = response
189189
.map { return $0[1] }
190-
.convertFromRESPValue(to: resultType)
190+
.map(to: resultType)
191191

192192
return position.and(elements)
193193
}

Sources/RediStack/Commands/HashCommands.swift

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ extension RedisClient {
5353
args.append(convertingContentsOf: fields)
5454

5555
return send(command: "HDEL", with: args)
56-
.convertFromRESPValue()
56+
.map()
5757
}
5858

5959
/// Removes the specified fields from a hash.
@@ -82,7 +82,7 @@ extension RedisClient {
8282
.init(bulk: field)
8383
]
8484
return send(command: "HEXISTS", with: args)
85-
.convertFromRESPValue(to: Int.self)
85+
.map(to: Int.self)
8686
.map { return $0 == 1 }
8787
}
8888

@@ -95,7 +95,7 @@ extension RedisClient {
9595
public func hlen(of key: RedisKey) -> EventLoopFuture<Int> {
9696
let args = [RESPValue(bulk: key)]
9797
return send(command: "HLEN", with: args)
98-
.convertFromRESPValue()
98+
.map()
9999
}
100100

101101
/// Gets the string length of a hash field's value.
@@ -112,7 +112,7 @@ extension RedisClient {
112112
.init(bulk: field)
113113
]
114114
return send(command: "HSTRLEN", with: args)
115-
.convertFromRESPValue()
115+
.map()
116116
}
117117

118118
/// Gets all field names in a hash.
@@ -124,7 +124,7 @@ extension RedisClient {
124124
public func hkeys(in key: RedisKey) -> EventLoopFuture<[String]> {
125125
let args = [RESPValue(bulk: key)]
126126
return send(command: "HKEYS", with: args)
127-
.convertFromRESPValue()
127+
.map()
128128
}
129129

130130
/// Gets all values stored in a hash.
@@ -136,7 +136,7 @@ extension RedisClient {
136136
public func hvals(in key: RedisKey) -> EventLoopFuture<[RESPValue]> {
137137
let args = [RESPValue(bulk: key)]
138138
return send(command: "HVALS", with: args)
139-
.convertFromRESPValue()
139+
.map()
140140
}
141141

142142
/// Incrementally iterates over all fields in a hash.
@@ -187,7 +187,7 @@ extension RedisClient {
187187
value.convertedToRESPValue()
188188
]
189189
return send(command: "HSET", with: args)
190-
.convertFromRESPValue(to: Int.self)
190+
.map(to: Int.self)
191191
.map { return $0 == 1 }
192192
}
193193

@@ -212,7 +212,7 @@ extension RedisClient {
212212
value.convertedToRESPValue()
213213
]
214214
return send(command: "HSETNX", with: args)
215-
.convertFromRESPValue(to: Int.self)
215+
.map(to: Int.self)
216216
.map { return $0 == 1 }
217217
}
218218

@@ -276,7 +276,7 @@ extension RedisClient {
276276
args.append(convertingContentsOf: fields)
277277

278278
return send(command: "HMGET", with: args)
279-
.convertFromRESPValue(to: [RESPValue].self)
279+
.map(to: [RESPValue].self)
280280
.map { return $0.map(String.init) }
281281
}
282282

@@ -301,7 +301,7 @@ extension RedisClient {
301301
public func hgetall(from key: RedisKey) -> EventLoopFuture<[String: String]> {
302302
let args = [RESPValue(bulk: key)]
303303
return send(command: "HGETALL", with: args)
304-
.convertFromRESPValue(to: [String].self)
304+
.map(to: [String].self)
305305
.map(Self._mapHashResponse)
306306
}
307307
}
@@ -352,6 +352,6 @@ extension RedisClient {
352352
amount.convertedToRESPValue()
353353
]
354354
return send(command: command, with: args)
355-
.convertFromRESPValue()
355+
.map()
356356
}
357357
}

Sources/RediStack/Commands/ListCommands.swift

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ extension RedisClient {
2626
public func llen(of key: RedisKey) -> EventLoopFuture<Int> {
2727
let args = [RESPValue(bulk: key)]
2828
return send(command: "LLEN", with: args)
29-
.convertFromRESPValue()
29+
.map()
3030
}
3131

3232
/// Gets the element from a list stored at the provided index position.
@@ -88,7 +88,7 @@ extension RedisClient {
8888
value.convertedToRESPValue()
8989
]
9090
return send(command: "LREM", with: args)
91-
.convertFromRESPValue()
91+
.map()
9292
}
9393
}
9494

@@ -257,7 +257,7 @@ extension RedisClient {
257257
.init(bulk: lastIndex)
258258
]
259259
return send(command: "LRANGE", with: args)
260-
.convertFromRESPValue()
260+
.map()
261261
}
262262

263263
/// Gets all elements from a List within the specified inclusive bounds of 0-based indices.
@@ -502,7 +502,7 @@ extension RedisClient {
502502
element.convertedToRESPValue()
503503
]
504504
return send(command: "LINSERT", with: args)
505-
.convertFromRESPValue()
505+
.map()
506506
}
507507
}
508508

@@ -536,7 +536,7 @@ extension RedisClient {
536536
args.append(convertingContentsOf: elements)
537537

538538
return send(command: "LPUSH", with: args)
539-
.convertFromRESPValue()
539+
.map()
540540
}
541541

542542
/// Pushes all of the provided elements into a list.
@@ -567,7 +567,7 @@ extension RedisClient {
567567
element.convertedToRESPValue()
568568
]
569569
return send(command: "LPUSHX", with: args)
570-
.convertFromRESPValue()
570+
.map()
571571
}
572572
}
573573

@@ -600,7 +600,7 @@ extension RedisClient {
600600
args.append(convertingContentsOf: elements)
601601

602602
return send(command: "RPUSH", with: args)
603-
.convertFromRESPValue()
603+
.map()
604604
}
605605

606606
/// Pushes all of the provided elements into a list.
@@ -630,7 +630,7 @@ extension RedisClient {
630630
element.convertedToRESPValue()
631631
]
632632
return send(command: "RPUSHX", with: args)
633-
.convertFromRESPValue()
633+
.map()
634634
}
635635
}
636636

Sources/RediStack/Commands/SetCommands.swift

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ extension RedisClient {
2929
public func smembers(of key: RedisKey) -> EventLoopFuture<[RESPValue]> {
3030
let args = [RESPValue(bulk: key)]
3131
return send(command: "SMEMBERS", with: args)
32-
.convertFromRESPValue()
32+
.map()
3333
}
3434

3535
/// Checks if the element is included in a set.
@@ -46,7 +46,7 @@ extension RedisClient {
4646
element.convertedToRESPValue()
4747
]
4848
return send(command: "SISMEMBER", with: args)
49-
.convertFromRESPValue(to: Int.self)
49+
.map(to: Int.self)
5050
.map { return $0 == 1 }
5151
}
5252

@@ -59,7 +59,7 @@ extension RedisClient {
5959
public func scard(of key: RedisKey) -> EventLoopFuture<Int> {
6060
let args = [RESPValue(bulk: key)]
6161
return send(command: "SCARD", with: args)
62-
.convertFromRESPValue()
62+
.map()
6363
}
6464

6565
/// Adds elements to a set.
@@ -77,7 +77,7 @@ extension RedisClient {
7777
args.append(convertingContentsOf: elements)
7878

7979
return send(command: "SADD", with: args)
80-
.convertFromRESPValue()
80+
.map()
8181
}
8282

8383
/// Adds elements to a set.
@@ -107,7 +107,7 @@ extension RedisClient {
107107
args.append(convertingContentsOf: elements)
108108

109109
return send(command: "SREM", with: args)
110-
.convertFromRESPValue()
110+
.map()
111111
}
112112

113113
/// Removes elements from a set.
@@ -140,7 +140,7 @@ extension RedisClient {
140140
.init(bulk: count)
141141
]
142142
return send(command: "SPOP", with: args)
143-
.convertFromRESPValue()
143+
.map()
144144
}
145145

146146
/// Randomly selects one or more elements in a set.
@@ -163,7 +163,7 @@ extension RedisClient {
163163
.init(bulk: count)
164164
]
165165
return send(command: "SRANDMEMBER", with: args)
166-
.convertFromRESPValue()
166+
.map()
167167
}
168168

169169
/// Moves an element from one set to another.
@@ -188,7 +188,7 @@ extension RedisClient {
188188
element.convertedToRESPValue()
189189
]
190190
return send(command: "SMOVE", with: args)
191-
.convertFromRESPValue()
191+
.map()
192192
.map { return $0 == 1 }
193193
}
194194

@@ -226,7 +226,7 @@ extension RedisClient {
226226

227227
let args = keys.map(RESPValue.init)
228228
return send(command: "SDIFF", with: args)
229-
.convertFromRESPValue()
229+
.map()
230230
}
231231

232232
/// Calculates the difference between two or more sets.
@@ -255,7 +255,7 @@ extension RedisClient {
255255
args.append(convertingContentsOf: keys)
256256

257257
return send(command: "SDIFFSTORE", with: args)
258-
.convertFromRESPValue()
258+
.map()
259259
}
260260
}
261261

@@ -273,7 +273,7 @@ extension RedisClient {
273273

274274
let args = keys.map(RESPValue.init)
275275
return send(command: "SINTER", with: args)
276-
.convertFromRESPValue()
276+
.map()
277277
}
278278

279279
/// Calculates the intersection of two or more sets.
@@ -302,7 +302,7 @@ extension RedisClient {
302302
args.append(convertingContentsOf: keys)
303303

304304
return send(command: "SINTERSTORE", with: args)
305-
.convertFromRESPValue()
305+
.map()
306306
}
307307
}
308308

@@ -320,7 +320,7 @@ extension RedisClient {
320320

321321
let args = keys.map(RESPValue.init)
322322
return send(command: "SUNION", with: args)
323-
.convertFromRESPValue()
323+
.map()
324324
}
325325

326326
/// Calculates the union of two or more sets.
@@ -349,6 +349,6 @@ extension RedisClient {
349349
args.append(convertingContentsOf: keys)
350350

351351
return send(command: "SUNIONSTORE", with: args)
352-
.convertFromRESPValue()
352+
.map()
353353
}
354354
}

0 commit comments

Comments
 (0)