项目作者: gialib

项目描述 :
Elixir Memcache Cache Client
高级语言: Elixir
项目地址: git://github.com/gialib/memcache_elixir.git
创建时间: 2018-05-30T15:02:01Z
项目社区:https://github.com/gialib/memcache_elixir

开源协议:

下载


Installing

You can install Memcache by adding it as a dependecy to your
project’s mix.exs file:

  1. defp deps do
  2. [
  3. {:memcache, "~> 0.1.2"}
  4. ]
  5. end

Examples

Get value for a key:

  1. response = Memcache.get("key")
  2. case response.status do
  3. :ok ->
  4. {:ok, response.value}
  5. status ->
  6. {:error, status}
  7. end

Fetch

  1. value = Memcache.fetch!("hello", fn ->
  2. "world"
  3. end)
  4. # value == "world"
  5. value = Memcache.fetch!("hello", fn ->
  6. "world2"
  7. end)
  8. # value == "world"

Config like this

  1. config :memcache,
  2. host: "127.0.0.1",
  3. port: 11211,
  4. auth_method: :none,
  5. username: "",
  6. password: "",
  7. pool_size: 10,
  8. pool_max_overflow: 20,
  9. namespace: "default"