Пример #1
0
func defaultMkConn(b *couchbase.Bucket, h string) (*mc.Client, error) {
	if conn, err := mc.Connect("tcp", h); err != nil {
		return nil, err
	} else {
		if _, err = conn.Auth(b.Name, ""); err != nil {
			conn.Close()
			return nil, err
		}
		return conn, nil
	}
}
Пример #2
0
func NewMemcache() *memcache.Client {
	m, err := memcache.Connect("tcp", config.MemcacheURL)
	if err != nil {
		panic(err)
	}

	if config.MemcacheUsername != "" {
		m.Auth(config.MemcacheUsername, config.MemcachePassword)
	}

	log.Println("Memcache Healthy", m.IsHealthy())
	log.Println(m.Set(0, "test", 0, 5, []byte("Testing...")))
	log.Println(m.Get(0, "test"))

	return m
}