mirror of
https://github.com/redis/go-redis.git
synced 2025-07-29 17:41:15 +03:00
Add NewUnixClient to connect to the unix sockets.
This commit is contained in:
10
redis.go
10
redis.go
@ -32,6 +32,12 @@ func TLSConnector(addr string, tlsConfig *tls.Config) OpenConnFunc {
|
||||
}
|
||||
}
|
||||
|
||||
func UnixConnector(addr string) OpenConnFunc {
|
||||
return func() (net.Conn, error) {
|
||||
return net.DialTimeout("unix", addr, 3*time.Second)
|
||||
}
|
||||
}
|
||||
|
||||
func AuthSelectFunc(password string, db int64) InitConnFunc {
|
||||
if password == "" && db < 0 {
|
||||
return nil
|
||||
@ -182,3 +188,7 @@ func NewTLSClient(addr string, tlsConfig *tls.Config, password string, db int64)
|
||||
AuthSelectFunc(password, db),
|
||||
)
|
||||
}
|
||||
|
||||
func NewUnixClient(addr string, password string, db int64) *Client {
|
||||
return NewClient(UnixConnector(addr), nil, AuthSelectFunc(password, db))
|
||||
}
|
||||
|
Reference in New Issue
Block a user