Gomemcached
is a Golang Memcached client designed to interact with multiple instances as shards. Implements sharding using a Consistent Hash.
- name: MEMCACHED_HEADLESS_SERVICE_ADDRESS
value: "my-memchached-service-headless.namespace.svc.cluster.local"
MEMCACHED_HEADLESS_SERVICE_ADDRESS
groups all memcached instances by ip addresses using dns lookup.
Default Memcached port is 11211
, but you can also specify it in config.
- name: MEMCACHED_PORT
value: "12345"
For local run or if you have a static amount and setup of pods you can specify Servers (list separated by commas along with the port) manually instead of setting the HeadlessServiceAddress:
- name: MEMCACHED_SERVERS
value: "127.0.0.1:11211,192.168.0.1:1234"
Initialization client and connected to memcached servers.
mcl, err := memcached.InitFromEnv()
mustInit(err)
a.AddCloser(func () error {
mcl.CloseAllConns()
return nil
})
To use SASL specify option for InitFromEnv:
memcached.InitFromEnv(memcached.WithAuthentication("<login>", "<password>"))
Can use Options with InitFromEnv to customize the client to suit your needs. However, for basic use, it is recommended to use the default client implementation.
This project is developed and tested with the following recommended versions:
-
Go: 1.21 or higher
-
Memcached: 1.6.9 or higher
This project utilizes the following third-party libraries, each governed by the MIT License:
-
- Description: A Go client library for the memcached server.
- Used for: Primary client methods for interacting with the library.
- License: Apache License 2.0
-
- Description: A cloud-native Go microservices framework with cli tool for productivity.
- Used for: Implementation of Consistent Hash.
- License: MIT License
-
- Description: A memcached binary protocol toolkit for go.
- Used for: Implementation of a binary client for Memcached.
- License: MIT License
Please review the respective license files in the linked repositories for more details.