File tree Expand file tree Collapse file tree 2 files changed +14
-0
lines changed Expand file tree Collapse file tree 2 files changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -11,6 +11,13 @@ extension NIORedisConnection {
11
11
. map { _ in return ( ) }
12
12
}
13
13
14
+ /// Request for authentication in a password-protected Redis server.
15
+ ///
16
+ /// https://redis.io/commands/auth
17
+ public func authorize( with password: String ) -> EventLoopFuture < Void > {
18
+ return command ( " AUTH " , [ RedisData ( bulk: password) ] ) . map { _ in return ( ) }
19
+ }
20
+
14
21
/// Removes the specified keys. A key is ignored if it does not exist.
15
22
///
16
23
/// https://redis.io/commands/del
Original file line number Diff line number Diff line change @@ -50,6 +50,13 @@ public final class NIORedis {
50
50
51
51
return bootstrap. connect ( host: hostname, port: port)
52
52
. map { return NIORedisConnection ( channel: $0, handler: channelHandler) }
53
+ . then { connection in
54
+ guard let pw = password else {
55
+ return self . elg. next ( ) . makeSucceededFuture ( result: connection)
56
+ }
57
+
58
+ return connection. authorize ( with: pw) . map { _ in return connection }
59
+ }
53
60
}
54
61
55
62
/// Handles the proper shutdown of managed resources.
You can’t perform that action at this time.
0 commit comments