Git Product home page Git Product logo

memcachir's Introduction

Memcachir

Build Status

Memcached client for Elixir. It supports clusters and AWS Elasticache.

Installation

defp deps() do
  ...
  {:memcachir, "~> 3.3"},
  ...
end

defp application() do
  [applications: [:logger, :memcachir, ...]]
end
config :memcachir,
  hosts: "localhost"

The hosts config allows multiple variants:

hosts: "localhost:11212"  # specify port
hosts: ["host1", "host2", "host3:11212"]  # cluster of servers
hosts: [{"host1", 10}, {"host2", 30}]  # cluster with weights

Alternatively you can use the elasticache config option:

config :memcachir,
  elasticache: "your-config-endpoint.cache.amazonaws.com"

Configuration

Complete configuration options with default values:

config :memcachir,
  hosts: "localhost",
  # memcached options
  ttl: 0,
  namespace: nil,
  # connection pool options
  pool: [
    strategy: :lifo,
    size: 10,
    max_overflow: 10]

Service Discovery

If you don't want to use the built in service discovery methods (host list, elasticache), you can implement the Herd.Discovery behavior, which just has a single nodes/0 callback. Then configure it in with:

config :memcachir, :service_discovery, MyMemcacheServiceDiscovery

(NB you'll need to delete the config :memcachir, :hosts and config :memcachir, :elasticache entries to use a custom service discovery module)

Example

iex> Memcachir.set("hello", "world")
{:ok}
iex> Memcachir.get("hello")
{:ok, "world"}

Example with ttl (in seconds)

iex> Memcachir.set("hello", "world", ttl: 5)
{:ok}
iex> Memcachir.get("hello")
{:ok, "world"}
iex> :timer.sleep(5001)
:ok
iex> Memcachir.get("hello")
{:error, "Key not found"}

memcachir's People

Contributors

peillis avatar michaeljguarino avatar stephanos avatar agutierrezrodriguez avatar natashadowse avatar

Forkers

pari-dhanakoti

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.