1
0
mirror of https://github.com/redis/go-redis.git synced 2025-07-28 06:42:00 +03:00

Clarify thread safety. Fixes #166.

This commit is contained in:
Vladimir Mihailenco
2015-09-12 09:36:03 +03:00
parent 02154c3b3a
commit c809246d8b
8 changed files with 33 additions and 16 deletions

View File

@ -80,6 +80,9 @@ func (c *baseClient) process(cmd Cmder) {
}
// Close closes the client, releasing any open resources.
//
// It is rare to Close a Client, as the Client is meant to be
// long-lived and shared between many goroutines.
func (c *baseClient) Close() error {
return c.connPool.Close()
}
@ -173,6 +176,9 @@ func (opt *Options) getIdleTimeout() time.Duration {
//------------------------------------------------------------------------------
// Client is a Redis client representing a pool of zero or more
// underlying connections. It's safe for concurrent use by multiple
// goroutines.
type Client struct {
*baseClient
commandable
@ -186,6 +192,7 @@ func newClient(opt *Options, pool pool) *Client {
}
}
// NewClient returns a client to the Redis Server specified by Options.
func NewClient(opt *Options) *Client {
pool := newConnPool(opt)
return newClient(opt, pool)