Skip to content

Latest commit

 

History

History
50 lines (39 loc) · 1.67 KB

README.md

File metadata and controls

50 lines (39 loc) · 1.67 KB

go-memcachey

GoDoc CircleCI

go-memcachey is a Golang client library for the Memcached in-memory database. See godoc for documentation.

Example

Basic Example

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)
}

Customized client

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)
}

Contributing

Testing

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