RedisPool
Redis connection pool using Poolboy and Exredis.
Installation
Add the following to your list of dependencies in mix.exs:
def deps do
[{:redis_connection_pool, "~> 0.1.5"}]
endSetup
Add the following to your list of applications in mix.exs.
def application do
# Specify extra applications you'll use from Erlang/Elixir
[extra_applications: [:redis_connection_pool]]
end
Add the following to your configuration in config/confix.exs.
config :redis_connection_pool, [
host: "127.0.0.1",
port: 6379,
password: "",
db: 0,
reconnect: :no_reconnect,
pool_name: :"Redis.Pool",
pool_size: 10,
pool_max_overflow: 1
]Or use with the full_url option.
config :redis_connection_pool, [
full_url: "redis://127.0.0.1:6379",
reconnect: :no_reconnect,
pool_name: :"Redis.Pool",
pool_size: 10,
pool_max_overflow: 1
]Usage
alias RedisPool, as: Redis
Redis.query(["SET", "key1", "value1"]) => {:ok, "OK"}
Redis.query(["GET", "key1"]) => {:ok, "value1"}
Redis.query(["GET", "key2"]) => {:undefined, nil}