-
Notifications
You must be signed in to change notification settings - Fork 10
/
config.go
69 lines (64 loc) · 1.8 KB
/
config.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package mc
//
import (
"time"
)
// Config holds the Memcache client configuration. Use DefaultConfig to get
// an initialized version.
type Config struct {
Hasher hasher
Retries int
RetryDelay time.Duration
Failover bool
// ConnectionTimeout is currently used to timeout getting connections from
// pool, as a sending deadline and as a reading deadline. Worst case this
// means a request can take 3 times the ConnectionTimeout.
ConnectionTimeout time.Duration
DownRetryDelay time.Duration
PoolSize int
TcpKeepAlive bool
TcpKeepAlivePeriod time.Duration
TcpNoDelay bool
Compression struct {
Decompress func(value string) (string, error)
Compress func(value string) (string, error)
}
}
/*
DefaultConfig returns a config object populated with the default values.
The default values currently are:
config{
Hasher: NewModuloHasher(),
Retries: 2,
RetryDelay: 200 * time.Millisecond,
Failover: true,
ConnectionTimeout: 2 * time.Second,
DownRetryDelay: 60 * time.Second,
PoolSize: 1,
TcpKeepAlive: true,
TcpKeepAlivePeriod: 60 * time.Second,
TcpNoDelay: true,
Compression struct {
Decompress nil
Compress nil
}
}
*/
func DefaultConfig() *Config {
return &Config{
Hasher: NewModuloHasher(),
Retries: 2,
RetryDelay: 200 * time.Millisecond,
Failover: true,
ConnectionTimeout: 2 * time.Second,
DownRetryDelay: 60 * time.Second,
PoolSize: 1,
TcpKeepAlive: true,
TcpKeepAlivePeriod: 60 * time.Second,
TcpNoDelay: true,
Compression: struct {
Decompress func(value string) (string, error)
Compress func(value string) (string, error)
}{Decompress: nil, Compress: nil},
}
}