12
12
//
13
13
//===----------------------------------------------------------------------===//
14
14
15
+ import struct Logging. Logger
15
16
import NIO
16
17
17
18
// MARK: Key
@@ -94,20 +95,34 @@ extension RedisClient {
94
95
/// Deletes the given keys. Any key that does not exist is ignored.
95
96
///
96
97
/// See ``RedisCommand/.del(keys:)``
97
- /// - Parameter keys: The list of keys to delete from the database.
98
+ /// - Parameters:
99
+ /// - keys: The list of keys to delete from the database.
100
+ /// - eventLoop: An optional event loop to hop to for any further chaining on the returned event loop future.
101
+ /// - logger: An optional logger instance to use for logs generated from this command.
98
102
/// - Returns: A `NIO.EventLoopFuture` that resolves the number of keys that were deleted from the database.
99
- public func delete( _ keys: RedisKey ... ) -> EventLoopFuture < Int > {
100
- return self . delete ( keys)
103
+ public func delete(
104
+ _ keys: RedisKey ... ,
105
+ eventLoop: EventLoop ? = nil ,
106
+ logger: Logger ? = nil
107
+ ) -> EventLoopFuture < Int > {
108
+ return self . delete ( keys, eventLoop: eventLoop, logger: logger)
101
109
}
102
110
103
111
/// Deletes the given keys. Any key that does not exist is ignored.
104
112
///
105
113
/// See ``RedisCommand/del(keys:)``
106
- /// - Parameter keys: The list of keys to delete from the database.
114
+ /// - Parameters:
115
+ /// - keys: The list of keys to delete from the database.
116
+ /// - eventLoop: An optional event loop to hop to for any further chaining on the returned event loop future.
117
+ /// - logger: An optional logger instance to use for logs generated from this command.
107
118
/// - Returns: A `NIO.EventLoopFuture` that resolves the number of keys that were deleted from the database.
108
- public func delete( _ keys: [ RedisKey ] ) -> EventLoopFuture < Int > {
119
+ public func delete(
120
+ _ keys: [ RedisKey ] ,
121
+ eventLoop: EventLoop ? = nil ,
122
+ logger: Logger ? = nil
123
+ ) -> EventLoopFuture < Int > {
109
124
guard keys. count > 0 else { return self . eventLoop. makeSucceededFuture ( 0 ) }
110
- return self . send ( . del( keys) )
125
+ return self . send ( . del( keys) , eventLoop : eventLoop , logger : logger )
111
126
}
112
127
113
128
/// Sets a timeout on key. After the timeout has expired, the key will automatically be deleted.
@@ -116,18 +131,32 @@ extension RedisClient {
116
131
/// - Parameters:
117
132
/// - key: The key to set the expiration on.
118
133
/// - timeout: The time from now the key will expire at.
134
+ /// - eventLoop: An optional event loop to hop to for any further chaining on the returned event loop future.
135
+ /// - logger: An optional logger instance to use for logs generated from this command.
119
136
/// - Returns: A `NIO.EventLoopFuture` that resolves `true` if the expiration was set and `false` if it wasn't.
120
- public func expire( _ key: RedisKey , after timeout: TimeAmount ) -> EventLoopFuture < Bool > {
121
- return self . send ( . expire( key, after: timeout) )
137
+ public func expire(
138
+ _ key: RedisKey ,
139
+ after timeout: TimeAmount ,
140
+ eventLoop: EventLoop ? = nil ,
141
+ logger: Logger ? = nil
142
+ ) -> EventLoopFuture < Bool > {
143
+ return self . send ( . expire( key, after: timeout) , eventLoop: eventLoop, logger: logger)
122
144
}
123
145
124
146
/// Searches the keys in the database that match the given pattern.
125
147
///
126
148
/// See ``RedisCommand/keys(matching:)``
127
- /// - Parameter pattern: The key pattern to search for matching keys that exist in Redis.
149
+ /// - Parameters:
150
+ /// - pattern: The key pattern to search for matching keys that exist in Redis.
151
+ /// - eventLoop: An optional event loop to hop to for any further chaining on the returned event loop future.
152
+ /// - logger: An optional logger instance to use for logs generated from this command.
128
153
/// - Returns: A result set of ``RedisKey`` values that exist and match the provided pattern.
129
- public func listKeys( matching pattern: String ) -> EventLoopFuture < [ RedisKey ] > {
130
- return self . send ( . keys( matching: pattern) )
154
+ public func listKeys(
155
+ matching pattern: String ,
156
+ eventLoop: EventLoop ? = nil ,
157
+ logger: Logger ? = nil
158
+ ) -> EventLoopFuture < [ RedisKey ] > {
159
+ return self . send ( . keys( matching: pattern) , eventLoop: eventLoop, logger: logger)
131
160
}
132
161
133
162
/// Incrementally iterates over all keys in the currently selected database.
@@ -137,12 +166,16 @@ extension RedisClient {
137
166
/// - position: The cursor position to start from.
138
167
/// - match: A glob-style pattern to filter values to be selected from the result set.
139
168
/// - count: The number of elements to advance by. Redis default is 10.
169
+ /// - eventLoop: An optional event loop to hop to for any further chaining on the returned event loop future.
170
+ /// - logger: An optional logger instance to use for logs generated from this command.
140
171
/// - Returns: A cursor position for additional invocations with a limited collection of keys found in the database.
141
172
public func scanKeys(
142
173
startingFrom position: Int = 0 ,
143
174
matching match: String ? = nil ,
144
- count: Int ? = nil
175
+ count: Int ? = nil ,
176
+ eventLoop: EventLoop ? = nil ,
177
+ logger: Logger ? = nil
145
178
) -> EventLoopFuture < ( Int , [ RedisKey ] ) > {
146
- return self . send ( . scan( startingFrom: position, matching: match, count: count) )
179
+ return self . send ( . scan( startingFrom: position, matching: match, count: count) , eventLoop : eventLoop , logger : logger )
147
180
}
148
181
}
0 commit comments