File tree 2 files changed +20
-1
lines changed
2 files changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -48,6 +48,10 @@ public class Redis {
48
48
callback ( nil )
49
49
}
50
50
}
51
+
52
+ public func disconnect( ) {
53
+ respHandle? . disconnect ( )
54
+ }
51
55
52
56
/// Authenticate against the server
53
57
///
@@ -61,7 +65,18 @@ public class Redis {
61
65
callback ( error)
62
66
}
63
67
}
64
-
68
+
69
+ public func auth( _ username: String , _ pswd: String , callback: ( NSError ? ) -> Void ) {
70
+ if username == " " {
71
+ return auth ( pswd, callback: callback)
72
+ }
73
+ issueCommand ( " AUTH " , username, pswd) { ( response: RedisResponse ) in
74
+ let ( _, error) = self . redisOkResponseHandler ( response, nilOk: false )
75
+ callback ( error)
76
+ }
77
+ }
78
+
79
+
65
80
/// Select the database to use
66
81
///
67
82
/// - Parameter db: numeric index for the database.
Original file line number Diff line number Diff line change @@ -46,6 +46,10 @@ public class RedisResp {
46
46
try ? socket? . connect ( to: host, port: port)
47
47
}
48
48
49
+ func disconnect( ) {
50
+ socket? . close ( )
51
+ }
52
+
49
53
func issueCommand( _ stringArgs: [ String ] , callback: ( RedisResponse ) -> Void ) {
50
54
guard let socket = socket else { return }
51
55
You can’t perform that action at this time.
0 commit comments