产品文档

云缓存 Memcached

go客户端: gomemcache(该客户端不支持密码连接)

客户端介绍:

https://godoc.org/github.com/bradfitz/gomemcache/memcache

将客户端包下载到GOPATH:

go get github.com/bradfitz/gomemcache/memcache

go代码示例:

package gomemcached

import (
	"fmt"
	"github.com/bradfitz/gomemcache/memcache"
)

func main() {
	mc := memcache.New("ip:port")//可通过添加多个实例的ip:port来实现集群版客户端
	mc.Set(&memcache.Item{Key: "key", Value: [ ]byte("value")})

	it, err := mc.Get("key")
	if err != nil {
		panic(err)
	}

	fmt.Printf("Value: %s", it.Value)
}
更新时间:2020-01-08 17:33:38