PhoenixSessionRedis
PhoenixSessionRedis provide redis pool and Plug.Session.REDIS. Depends on eredis, poolboy and plug.
It is assumed that application is created Phoenix Framework and run multi(or one) web server with one redis server for session. But not limited Phoenix Framework.
Installation
If available in Hex, the package can be installed as:
-
Add
phoenix_session_redisto your list of dependencies inmix.exs:
```elixir
def deps do
[{:phoenix_session_redis, "~> 0.1.2"}]
end
```-
Ensure
phoenix_session_redisis started before your application:
```elixir
def application do
[applications: [:phoenix_session_redis]]
end
```Usage
Add below example to your Phoenix Framework project.
config/config.exs
config :phoenix_session_redis, :config, name: :redis_sessions, # Pool name pool: [ size: 2, # Number of worker max_overflow: 5, # Max Additional worker name: {:local, :redis_sessions} # First is determination where the pool is run # Second is unique pool name ], redis: [ # Worker arguments host: 'localhost', # Redis host(it is char list !) port: 6379, # Redis port ]lib/endpoint.ex
plug Plug.Session, store: :redis, # Plug.Session.REDIS module key: _session_key # Cookie name table: :redis_sessions, # Pool name ttl: 1 * 60 * 60 # Redis expiration max_age: 1 * 60 * 60 # Cookie expiration
Licence
See LICENSE.
Contribution
- Fork it
- Create your feature branch (git checkout -b my-new-feature)
- Commit your changes (git commit -am 'Add some feature')
- Push to the branch (git push origin my-new-feature)
- Create new Pull Request