https://github.com/aliexpressru/gomemcached
A Binary Memcached client for Go with support for sharding using consistent hashing, along with SASL.
https://github.com/aliexpressru/gomemcached
consistent-hashing go golang memcached memcached-clients
Last synced: 3 months ago
JSON representation
A Binary Memcached client for Go with support for sharding using consistent hashing, along with SASL.
- Host: GitHub
- URL: https://github.com/aliexpressru/gomemcached
- Owner: aliexpressru
- License: mit
- Created: 2024-01-19T14:10:56.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-02-19T07:08:35.000Z (over 1 year ago)
- Last Synced: 2024-07-31T20:50:47.860Z (10 months ago)
- Topics: consistent-hashing, go, golang, memcached, memcached-clients
- Language: Go
- Homepage:
- Size: 458 KB
- Stars: 19
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-go - gomemcached - A binary Memcached client for Go with support for sharding using consistent hashing, along with SASL. (Database Drivers / NoSQL Database Drivers)
README
# Gomemcached
---
![]()
[](https://github.com/aliexpressru/gomemcached)
[](https://github.com/aliexpressru/gomemcached/tags)
[](https://pkg.go.dev/github.com/aliexpressru/gomemcached)[](https://goreportcard.com/report/github.com/aliexpressru/gomemcached)
[](https://github.com/avelino/awesome-go?tab=readme-ov-file#nosql-database-drivers)
___
`Gomemcached` is a Golang Memcached client designed to interact with multiple instances as shards. Implements sharding using a Consistent Hash.
___### Configuration
```yaml
- 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.
```yaml
- 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:```yaml
- name: MEMCACHED_SERVERS
value: "127.0.0.1:11211,192.168.0.1:1234"
```___
### Usage
Initialization client and connected to memcached servers.
```go
mcl, err := memcached.InitFromEnv()
mustInit(err)
a.AddCloser(func () error {
mcl.CloseAllConns()
return nil
})
```
[More examples](examples/main.go)To use SASL specify option for InitFromEnv:
```go
memcached.InitFromEnv(memcached.WithAuthentication("", ""))
```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.---
### Recommended Versions
This project is developed and tested with the following recommended versions:
- Go: 1.21 or higher
- [Download Go](https://golang.org/dl/)- Memcached: 1.6.9 or higher
- [Memcached Releases](https://memcached.org/downloads)---
### Dependencies
This project utilizes the following third-party libraries, each governed by the MIT License:
1. [gomemcache](https://github.com/bradfitz/gomemcache)
- Description: A Go client library for the memcached server.
- Used for: Primary client methods for interacting with the library.
- License: Apache License 2.02. [go-zero](https://github.com/zeromicro/go-zero)
- Description: A cloud-native Go microservices framework with cli tool for productivity.
- Used for: Implementation of Consistent Hash.
- License: MIT License3. [gomemcached](https://github.com/dustin/gomemcached)
- Description: A memcached binary protocol toolkit for go.
- Used for: Implementation of a binary client for Memcached.
- License: MIT LicensePlease review the respective license files in the linked repositories for more details.