Memcachir
Memcached client for Elixir. It supports clusters and AWS Elasticache.
Installation
defp deps() do
...
{:memcachir, "~> 3.1"},
...
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]
Example
iex> Memcachir.set("hello", "world")
{:ok}
iex> Memcachir.get("hello")
{:ok, "world"}