Skip to content

Commit c010e13

Browse files
committed
50 -- Rename EventLoopFuture.mapFromRESP to convertFromRESPValue
1 parent e0e5a68 commit c010e13

File tree

7 files changed

+65
-65
lines changed

7 files changed

+65
-65
lines changed

Sources/RedisNIO/Commands/BasicCommands.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ extension RedisClient {
2323
@inlinable
2424
public func echo(_ message: String) -> EventLoopFuture<String> {
2525
return send(command: "ECHO", with: [message])
26-
.mapFromRESP()
26+
.convertFromRESPValue()
2727
}
2828

2929
/// Pings the server, which will respond with a message.
@@ -35,7 +35,7 @@ extension RedisClient {
3535
public func ping(with message: String? = nil) -> EventLoopFuture<String> {
3636
let arg = message != nil ? [message] : []
3737
return send(command: "PING", with: arg)
38-
.mapFromRESP()
38+
.convertFromRESPValue()
3939
}
4040

4141
/// Select the Redis logical database having the specified zero-based numeric index.
@@ -61,7 +61,7 @@ extension RedisClient {
6161
public func swapDatabase(_ first: Int, with second: Int) -> EventLoopFuture<Bool> {
6262
/// connection.swapDatabase(index: 0, withIndex: 10)
6363
return send(command: "SWAPDB", with: [first, second])
64-
.mapFromRESP(to: String.self)
64+
.convertFromRESPValue(to: String.self)
6565
.map { return $0 == "OK" }
6666
}
6767

@@ -75,7 +75,7 @@ extension RedisClient {
7575
guard keys.count > 0 else { return self.eventLoop.makeSucceededFuture(0) }
7676

7777
return send(command: "DEL", with: keys)
78-
.mapFromRESP()
78+
.convertFromRESPValue()
7979
}
8080

8181
/// Sets a timeout on key. After the timeout has expired, the key will automatically be deleted.
@@ -90,7 +90,7 @@ extension RedisClient {
9090
public func expire(_ key: String, after deadline: TimeAmount) -> EventLoopFuture<Bool> {
9191
let amount = deadline.nanoseconds / 1_000_000_000
9292
return send(command: "EXPIRE", with: [key, amount])
93-
.mapFromRESP(to: Int.self)
93+
.convertFromRESPValue(to: Int.self)
9494
.map { return $0 == 1 }
9595
}
9696
}
@@ -142,7 +142,7 @@ extension RedisClient {
142142
args.append(c)
143143
}
144144

145-
let response = send(command: command, with: args).mapFromRESP(to: [RESPValue].self)
145+
let response = send(command: command, with: args).convertFromRESPValue(to: [RESPValue].self)
146146
let position = response.flatMapThrowing { result -> Int in
147147
guard
148148
let value = result[0].string,
@@ -154,7 +154,7 @@ extension RedisClient {
154154
}
155155
let elements = response
156156
.map { return $0[1] }
157-
.mapFromRESP(to: resultType)
157+
.convertFromRESPValue(to: resultType)
158158

159159
return position.and(elements)
160160
}

Sources/RedisNIO/Commands/HashCommands.swift

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ extension RedisClient {
5050
guard fields.count > 0 else { return self.eventLoop.makeSucceededFuture(0) }
5151

5252
return send(command: "HDEL", with: [key] + fields)
53-
.mapFromRESP()
53+
.convertFromRESPValue()
5454
}
5555

5656
/// Checks if a hash contains the field specified.
@@ -63,7 +63,7 @@ extension RedisClient {
6363
@inlinable
6464
public func hexists(_ field: String, in key: String) -> EventLoopFuture<Bool> {
6565
return send(command: "HEXISTS", with: [key, field])
66-
.mapFromRESP(to: Int.self)
66+
.convertFromRESPValue(to: Int.self)
6767
.map { return $0 == 1 }
6868
}
6969

@@ -75,7 +75,7 @@ extension RedisClient {
7575
@inlinable
7676
public func hlen(of key: String) -> EventLoopFuture<Int> {
7777
return send(command: "HLEN", with: [key])
78-
.mapFromRESP()
78+
.convertFromRESPValue()
7979
}
8080

8181
/// Gets the string length of a hash field's value.
@@ -88,7 +88,7 @@ extension RedisClient {
8888
@inlinable
8989
public func hstrlen(of field: String, in key: String) -> EventLoopFuture<Int> {
9090
return send(command: "HSTRLEN", with: [key, field])
91-
.mapFromRESP()
91+
.convertFromRESPValue()
9292
}
9393

9494
/// Gets all field names in a hash.
@@ -99,7 +99,7 @@ extension RedisClient {
9999
@inlinable
100100
public func hkeys(in key: String) -> EventLoopFuture<[String]> {
101101
return send(command: "HKEYS", with: [key])
102-
.mapFromRESP()
102+
.convertFromRESPValue()
103103
}
104104

105105
/// Gets all values stored in a hash.
@@ -110,7 +110,7 @@ extension RedisClient {
110110
@inlinable
111111
public func hvals(in key: String) -> EventLoopFuture<[RESPValue]> {
112112
return send(command: "HVALS", with: [key])
113-
.mapFromRESP()
113+
.convertFromRESPValue()
114114
}
115115

116116
/// Incrementally iterates over all fields in a hash.
@@ -156,7 +156,7 @@ extension RedisClient {
156156
in key: String
157157
) -> EventLoopFuture<Bool> {
158158
return send(command: "HSET", with: [key, field, value])
159-
.mapFromRESP(to: Int.self)
159+
.convertFromRESPValue(to: Int.self)
160160
.map { return $0 == 1 }
161161
}
162162

@@ -176,7 +176,7 @@ extension RedisClient {
176176
in key: String
177177
) -> EventLoopFuture<Bool> {
178178
return send(command: "HSETNX", with: [key, field, value])
179-
.mapFromRESP(to: Int.self)
179+
.convertFromRESPValue(to: Int.self)
180180
.map { return $0 == 1 }
181181
}
182182

@@ -232,7 +232,7 @@ extension RedisClient {
232232
guard fields.count > 0 else { return self.eventLoop.makeSucceededFuture([]) }
233233

234234
return send(command: "HMGET", with: [key] + fields)
235-
.mapFromRESP(to: [RESPValue].self)
235+
.convertFromRESPValue(to: [RESPValue].self)
236236
.map { return $0.map(String.init) }
237237
}
238238

@@ -244,7 +244,7 @@ extension RedisClient {
244244
@inlinable
245245
public func hgetall(from key: String) -> EventLoopFuture<[String: String]> {
246246
return send(command: "HGETALL", with: [key])
247-
.mapFromRESP(to: [String].self)
247+
.convertFromRESPValue(to: [String].self)
248248
.map(Self._mapHashResponse)
249249
}
250250
}
@@ -264,7 +264,7 @@ extension RedisClient {
264264
public func hincrby(_ amount: Int, field: String, in key: String) -> EventLoopFuture<Int> {
265265
/// connection.hincrby(20, field: "foo", in: "key")
266266
return send(command: "HINCRBY", with: [key, field, amount])
267-
.mapFromRESP()
267+
.convertFromRESPValue()
268268
}
269269

270270
/// Increments a hash field's value and returns the new value.
@@ -282,6 +282,6 @@ extension RedisClient {
282282
T: RESPValueConvertible
283283
{
284284
return send(command: "HINCRBYFLOAT", with: [key, field, amount])
285-
.mapFromRESP()
285+
.convertFromRESPValue()
286286
}
287287
}

Sources/RedisNIO/Commands/ListCommands.swift

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ extension RedisClient {
2525
@inlinable
2626
public func llen(of key: String) -> EventLoopFuture<Int> {
2727
return send(command: "LLEN", with: [key])
28-
.mapFromRESP()
28+
.convertFromRESPValue()
2929
}
3030

3131
/// Gets the element from a list stored at the provided index position.
@@ -73,7 +73,7 @@ extension RedisClient {
7373
count: Int = 0
7474
) -> EventLoopFuture<Int> {
7575
return send(command: "LREM", with: [key, count, value])
76-
.mapFromRESP()
76+
.convertFromRESPValue()
7777
}
7878

7979
/// Trims a list to only contain elements within the specified inclusive bounds of 0-based indices.
@@ -103,7 +103,7 @@ extension RedisClient {
103103
from key: String
104104
) -> EventLoopFuture<[RESPValue]> {
105105
return send(command: "LRANGE", with: [key, range.startIndex, range.endIndex])
106-
.mapFromRESP()
106+
.convertFromRESPValue()
107107
}
108108

109109
/// Pops the last element from a source list and pushes it to a destination list.
@@ -187,7 +187,7 @@ extension RedisClient {
187187
_ pivot: RESPValueConvertible
188188
) -> EventLoopFuture<Int> {
189189
return send(command: "LINSERT", with: [key, pivotKeyword, pivot, element])
190-
.mapFromRESP()
190+
.convertFromRESPValue()
191191
}
192192
}
193193

@@ -217,7 +217,7 @@ extension RedisClient {
217217
assert(elements.count > 0, "At least 1 element should be provided.")
218218

219219
return send(command: "LPUSH", with: [key] + elements)
220-
.mapFromRESP()
220+
.convertFromRESPValue()
221221
}
222222

223223
/// Pushes an element into a list, but only if the key exists and holds a list.
@@ -231,7 +231,7 @@ extension RedisClient {
231231
@inlinable
232232
public func lpushx(_ element: RESPValueConvertible, into key: String) -> EventLoopFuture<Int> {
233233
return send(command: "LPUSHX", with: [key, element])
234-
.mapFromRESP()
234+
.convertFromRESPValue()
235235
}
236236
}
237237

@@ -260,7 +260,7 @@ extension RedisClient {
260260
assert(elements.count > 0, "At least 1 element should be provided.")
261261

262262
return send(command: "RPUSH", with: [key] + elements)
263-
.mapFromRESP()
263+
.convertFromRESPValue()
264264
}
265265

266266
/// Pushes an element into a list, but only if the key exists and holds a list.
@@ -274,7 +274,7 @@ extension RedisClient {
274274
@inlinable
275275
public func rpushx(_ element: RESPValueConvertible, into key: String) -> EventLoopFuture<Int> {
276276
return send(command: "RPUSHX", with: [key, element])
277-
.mapFromRESP()
277+
.convertFromRESPValue()
278278
}
279279
}
280280

Sources/RedisNIO/Commands/SetCommands.swift

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ extension RedisClient {
2828
@inlinable
2929
public func smembers(of key: String) -> EventLoopFuture<[RESPValue]> {
3030
return send(command: "SMEMBERS", with: [key])
31-
.mapFromRESP()
31+
.convertFromRESPValue()
3232
}
3333

3434
/// Checks if the element is included in a set.
@@ -41,7 +41,7 @@ extension RedisClient {
4141
@inlinable
4242
public func sismember(_ element: RESPValueConvertible, of key: String) -> EventLoopFuture<Bool> {
4343
return send(command: "SISMEMBER", with: [key, element])
44-
.mapFromRESP(to: Int.self)
44+
.convertFromRESPValue(to: Int.self)
4545
.map { return $0 == 1 }
4646
}
4747

@@ -53,7 +53,7 @@ extension RedisClient {
5353
@inlinable
5454
public func scard(of key: String) -> EventLoopFuture<Int> {
5555
return send(command: "SCARD", with: [key])
56-
.mapFromRESP()
56+
.convertFromRESPValue()
5757
}
5858

5959
/// Adds elements to a set.
@@ -68,7 +68,7 @@ extension RedisClient {
6868
guard elements.count > 0 else { return self.eventLoop.makeSucceededFuture(0) }
6969

7070
return send(command: "SADD", with: [key] + elements)
71-
.mapFromRESP()
71+
.convertFromRESPValue()
7272
}
7373

7474
/// Removes elements from a set.
@@ -83,7 +83,7 @@ extension RedisClient {
8383
guard elements.count > 0 else { return self.eventLoop.makeSucceededFuture(0) }
8484

8585
return send(command: "SREM", with: [key] + elements)
86-
.mapFromRESP()
86+
.convertFromRESPValue()
8787
}
8888

8989
/// Randomly selects and removes one or more elements in a set.
@@ -100,7 +100,7 @@ extension RedisClient {
100100
guard count > 0 else { return self.eventLoop.makeSucceededFuture([]) }
101101

102102
return send(command: "SPOP", with: [key, count])
103-
.mapFromRESP()
103+
.convertFromRESPValue()
104104
}
105105

106106
/// Randomly selects one or more elements in a set.
@@ -119,7 +119,7 @@ extension RedisClient {
119119
guard count != 0 else { return self.eventLoop.makeSucceededFuture([]) }
120120

121121
return send(command: "SRANDMEMBER", with: [key, count])
122-
.mapFromRESP()
122+
.convertFromRESPValue()
123123
}
124124

125125
/// Moves an element from one set to another.
@@ -139,7 +139,7 @@ extension RedisClient {
139139
guard sourceKey != destKey else { return self.eventLoop.makeSucceededFuture(true) }
140140

141141
return send(command: "SMOVE", with: [sourceKey, destKey, element])
142-
.mapFromRESP()
142+
.convertFromRESPValue()
143143
.map { return $0 == 1 }
144144
}
145145

@@ -176,7 +176,7 @@ extension RedisClient {
176176
guard keys.count > 0 else { return self.eventLoop.makeSucceededFuture([]) }
177177

178178
return send(command: "SDIFF", with: keys)
179-
.mapFromRESP()
179+
.convertFromRESPValue()
180180
}
181181

182182
/// Calculates the difference between two or more sets and stores the result.
@@ -192,7 +192,7 @@ extension RedisClient {
192192
assert(keys.count > 0, "At least 1 key should be provided.")
193193

194194
return send(command: "SDIFFSTORE", with: [destination] + keys)
195-
.mapFromRESP()
195+
.convertFromRESPValue()
196196
}
197197
}
198198

@@ -209,7 +209,7 @@ extension RedisClient {
209209
guard keys.count > 0 else { return self.eventLoop.makeSucceededFuture([]) }
210210

211211
return send(command: "SINTER", with: keys)
212-
.mapFromRESP()
212+
.convertFromRESPValue()
213213
}
214214

215215
/// Calculates the intersetion of two or more sets and stores the result.
@@ -225,7 +225,7 @@ extension RedisClient {
225225
assert(keys.count > 0, "At least 1 key should be provided.")
226226

227227
return send(command: "SINTERSTORE", with: [destination] + keys)
228-
.mapFromRESP()
228+
.convertFromRESPValue()
229229
}
230230
}
231231

@@ -242,7 +242,7 @@ extension RedisClient {
242242
guard keys.count > 0 else { return self.eventLoop.makeSucceededFuture([]) }
243243

244244
return send(command: "SUNION", with: keys)
245-
.mapFromRESP()
245+
.convertFromRESPValue()
246246
}
247247

248248
/// Calculates the union of two or more sets and stores the result.
@@ -258,6 +258,6 @@ extension RedisClient {
258258
assert(keys.count > 0, "At least 1 key should be provided.")
259259

260260
return send(command: "SUNIONSTORE", with: [destination] + keys)
261-
.mapFromRESP()
261+
.convertFromRESPValue()
262262
}
263263
}

0 commit comments

Comments
 (0)