Skip to content

A Binary Memcached client for Go with support for sharding using consistent hashing, along with SASL.

License

Notifications You must be signed in to change notification settings

aliexpressru/gomemcached

Repository files navigation

Gomemcached


License Tag Godoc

Gomemcached Coverage

Mentioned in Awesome Go


Gomemcached is a Golang Memcached client designed to interact with multiple instances as shards. Implements sharding using a Consistent Hash.


Configuration

    - 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"

Usage

Initialization client and connected to memcached servers.

    mcl, err := memcached.InitFromEnv()
    mustInit(err)
    a.AddCloser(func () error {
        mcl.CloseAllConns()
        return nil
    })

More examples

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.


Recommended Versions

This project is developed and tested with the following recommended versions:


Dependencies

This project utilizes the following third-party libraries, each governed by the MIT License:

  1. gomemcache

    • Description: A Go client library for the memcached server.
    • Used for: Primary client methods for interacting with the library.
    • License: Apache License 2.0
  2. go-zero

    • Description: A cloud-native Go microservices framework with cli tool for productivity.
    • Used for: Implementation of Consistent Hash.
    • License: MIT License
  3. gomemcached

    • 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.

About

A Binary Memcached client for Go with support for sharding using consistent hashing, along with SASL.

Topics

Resources

License

Stars

Watchers

Forks