Skip to content

Commit

Permalink
Define and use notWaitForRetryTimeout
Browse files Browse the repository at this point in the history
  • Loading branch information
jumpeiMano committed Sep 22, 2018
1 parent 74be8d5 commit c337f74
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/golibmc.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,13 @@ type Client struct {
maxOpen int // maximum amount of connection num. maxOpen <= 0 means unlimited.
cleanerCh chan struct{}
closed bool

// notWaitForRetryTimeout is used when you want to set MC_RETRY_TIMEOUT to 0.
// When retryTimeout is not set (= 0) and notWaitForRetryTimeout is true,
// MC_RETRY_TIMEOUT is set to 0.
// If retryTimeout is less than 1 second and notWaitForRetryTimeout is false,
// MC_RETRY_TIMEOUT is set to the default setting of 5 seconds.
notWaitForRetryTimeout bool
}

type connRequest struct {
Expand Down Expand Up @@ -346,7 +353,7 @@ func (client *Client) newConn() (*conn, error) {
)

cn.configHashFunction(int(hashFunctionMapping[client.hashFunc]))
if client.retryTimeout > 0 {
if client.retryTimeout > 0 || client.notWaitForRetryTimeout {
C.client_config(cn._imp, RetryTimeout, client.retryTimeout)
}
if client.pollTimeout > 0 {
Expand Down Expand Up @@ -600,6 +607,13 @@ func (client *Client) ConfigTimeout(cCfgKey C.config_options_t, timeout time.Dur
}
}

// ConfigNotWaitForRetryTimeout can set notWaitForRetryTimeout
func (client *Client) ConfigNotWaitForRetryTimeout(notWaitForRetryTimeout bool) {
client.lk.Lock()
defer client.lk.Unlock()
client.notWaitForRetryTimeout = notWaitForRetryTimeout
}

// GetServerAddressByKey will return the address of the memcached
// server where a key is stored (assume all memcached servers are
// accessiable and wonot establish any connections. )
Expand Down

0 comments on commit c337f74

Please sign in to comment.