This is a memcache client library for the Go programming language (http://golang.org/).
Install with:
$ go get github.com/arxignis/gomemcache/memcache
Then use it like:
import (
"github.com/arxignis/gomemcache/memcache"
)
func main() {
mc := memcache.New("10.0.0.1:11211", "10.0.0.2:11211", "10.0.0.3:11212")
mc.Set(&memcache.Item{Key: "foo", Value: []byte("my value")})
it, err := mc.Get("foo")
...
}
By default, the client uses gets
commands to support CAS (Compare-And-Swap) operations.
If your memcached setup does not support CAS or you want to disable it (e.g., for performance or compatibility),
you can set the DisableCAS
field on the client:
mc := memcache.New("127.0.0.1:11211")
mc.DisableCAS = true
When DisableCAS
is enabled:
- The client will use
get
instead ofgets
when fetching items. - CAS-based methods (like
CompareAndSwap
) will either be no-ops or fall back to simpler operations (e.g.,Set
).
See https://pkg.go.dev/github.com/arxignis/gomemcache/memcache
Or run:
$ godoc github.com/arxignis/gomemcache/memcache