go-memcachey is a Golang client library for the Memcached in-memory database. See godoc for documentation.
import "github.com/janberktold/go-memcachey"
func main() {
client, _ := memcachey.NewClient([]string{"127.0.0.1:11211"})
// Set a value to Memcached
client.Set("some_key", []byte{1, 2, 3})
// Read the value back
value, _ := client.Get("some_key")
fmt.Printf("Read %v from Memcached!", value)
}
func main() {
client, _ := memcachey.NewClient([]string{"127.0.0.1:11211"},
memcachey.WithConsistentHashing(),
memcachey.WithPoolLimitsPerHost(20, 100),
memcachey.WithTimeouts(10 * time.Second))
// Read a value from Memcached
value, _ := client.Get("some_key")
fmt.Printf("Read %v from Memcached!", value)
}
This client includes a testing suite which runs commands against a Memcached server running at 127.0.0.1:11211
. It is run on every opened pull request, but it is recommended to test locally beforehand. The easiest way to spin up the required Memcached server is to use Docker:
docker run --publish 127.0.0.1:11211:11211 memcached:1.5.17-alpine -v -v -v
After which you can execute the tests any number of times:
go test -v