コード例 #1
0
// NewMemcachedClient4T return a client that implements the text protocol.
func NewMemcachedClient4T(c *config.Config) (*MemcachedClient4T, error) {
	if len(c.Servers) == 0 {
		return nil, fmt.Errorf("Memcached : Servers must not empty")
	}

	if c.InitConns <= 0 {
		c.InitConns = 15
	}

	if c.NumberOfReplicas <= 0 {
		c.NumberOfReplicas = 20
	}

	if c.RefreshHashIntervalInSecond <= 0 {
		c.RefreshHashIntervalInSecond = 10
	}

	c.TextOrBinary = 0

	p, err := pool.New(c)
	if err != nil {
		return nil, err
	}

	tpp := parse.NewTextProtocolParse(p, c)

	return &MemcachedClient4T{tpp}, nil
}
コード例 #2
0
func new() *parse.TextProtocolParse {
	c := config.New()
	c.Servers = []string{"127.0.0.1:11211"}

	p, _ := pool.New(c)

	return parse.NewTextProtocolParse(p, c)
}