memgo is a Memcached client for Go.
import (
"github.com/wozaki/memgo"
)
func main() {
mc := memgo.NewClient(
[]string{"cache1.example.com:11211", "cache2.example.com:11211"},
memgo.Config{
ConnectTimeout: 100 * time.Millisecond,
Namespace: "app_v1",
})
mc.Set(mc.Item{Key: "foo", Value: "my value"})
res, err := mc.Get("foo")
...
}
go get github.com/wozaki/memgo
Feature | Description |
---|---|
Sharding | The algorithm is Consistent Hashing. |
Compression | The format follows compress/zlib. There are two kinds of compression: 1: compress automatically if an item size over the threshold. The default threshold size is 1MB. You can configure the threshold size with Config.CompressThresholdByte 2: compress manually if given CompressFlag with storage commands like Set(Item{Key: key, Value: val, Flags: Flags{Value: CompressFlag}}) . It will compress the item even if the size of item under the threshold. |
MIT Licensed. See the LICENSE file for details.