Nebulex adapter for Memcached

Build StatusCoverage Status

This adapter is implemented using Memcachex, a Memcached driver for Elixir.

This adapter supports multiple connection pools against different Memcached nodes in a cluster. This feature enables resiliency and also be able to survive in case any node(s) gets unreachable.

Installation

Add nebulex_memcached_adapter to your list of dependencies in mix.exs:

def deps do
  [
    {:nebulex_memcached_adapter, "~> 0.1.0"}
  ]
end

Usage

After installing, we can define our cache to use Memcached adapter as follows:

defmodule MyApp.MemcachedCache do
  use Nebulex.Cache,
    otp_app: :nebulex,
    adapter: NebulexMemcachedAdapter
end

The rest of Memcached configuration is set in our application environment, usually defined in your config/config.exs:

config :my_app, MyApp.MemcachedCache,
  pools: [
    primary: [
      host: "127.0.0.1",
      port: 11211,
      pool_size: 10
    ],
    #=> maybe more pools
  ]

Since this adapter is implemented by means of Memcachex, it inherits the same options, including regular Memcached options and connection options as well. For more information about the options, please check out NebulexMemcachedAdapter module and also Memcachex.

Testing

Docker

docker-compose run test

Without Docker

Ensure you have Memcached up and running on localhost(default host) and 11211(default port).

Since NebulexMemcachedAdapter uses the support modules and shared tests from Nebulex and by default its test folder is not included within the hex dependency, it is necessary to fetch :nebulex dependency directly from GtiHub.

Fetch deps:

$ MIX_ENV=test mix deps.get

Now we can run the tests:

$ mix test

Running tests with coverage:

$ mix coveralls.html

You can find the coverage report within cover/excoveralls.html.

Benchmarks

Benchmarks were added using benchee; to learn more, see the benchmarks directory.

To run the benchmarks:

$ mix deps.get && mix run benchmarks/benchmark.exs

Contributing

Contributions to Nebulex are very welcome and appreciated!

Use the issue tracker for bug reports or feature requests. Open a pull request when you are ready to contribute.

When submitting a pull request you should not update the CHANGELOG.md, and also make sure you test your changes thoroughly, include unit tests alongside new or changed code.

Before to submit a PR it is highly recommended to run:

Copyright and License

Copyright (c) 2018, Vasu Adari.

NebulexMemcachedAdapter source code is licensed under the MIT License.