Current section
3 Versions
Jump to
Current section
3 Versions
Compare versions
4
files changed
+40
additions
-14
deletions
| @@ -7,19 +7,19 @@ The main goal was to be able to use all Exredis.Api functions which automaticall | |
| 7 7 | |
| 8 8 | 1. Add `exredis_poolboy` to your list of dependencies in `mix.exs`: |
| 9 9 | |
| 10 | - ```elixir |
| 11 | - def deps do |
| 12 | - [{:exredis_poolboy, "~> 0.2.0"}] |
| 13 | - end |
| 14 | - ``` |
| 10 | + ```elixir |
| 11 | + def deps do |
| 12 | + [{:exredis_poolboy, "~> 0.2.0"}] |
| 13 | + end |
| 14 | + ``` |
| 15 15 | |
| 16 16 | 2. Ensure `exredis_poolboy` is started before your application: |
| 17 17 | |
| 18 | - ```elixir |
| 19 | - def application do |
| 20 | - [applications: [:exredis_poolboy]] |
| 21 | - end |
| 22 | - ``` |
| 18 | + ```elixir |
| 19 | + def application do |
| 20 | + [applications: [:exredis_poolboy]] |
| 21 | + end |
| 22 | + ``` |
| 23 23 | |
| 24 24 | ## Usage |
| 25 25 | |
| @@ -61,8 +61,8 @@ The main goal was to be able to use all Exredis.Api functions which automaticall | |
| 61 61 | 4. Use just like you would use exredis: |
| 62 62 | |
| 63 63 | ```elixir |
| 64 | - MyApp.Redis.llen("key") |
| 65 | - MyApp.Redis.sadd("key", "value") |
| 64 | + MyApp.Redis.llen("key") |
| 65 | + MyApp.Redis.sadd("key", "value") |
| 66 66 | ``` |
| 67 67 | |
| 68 68 | ## Overriding functions |
| @@ -21,4 +21,4 @@ | |
| 21 21 | {<<"name">>,<<"poolboy">>}, |
| 22 22 | {<<"optional">>,false}, |
| 23 23 | {<<"requirement">>,<<"~> 1.5">>}]]}. |
| 24 | - {<<"version">>,<<"0.2.1">>}. |
| 24 | + {<<"version">>,<<"0.2.2">>}. |
| @@ -1,6 +1,32 @@ | |
| 1 1 | defmodule ExredisPoolboy.FunctionsDefinitions do |
| 2 2 | @moduledoc """ |
| 3 3 | Defines all public functions from Exredis.Api module that are executed by poolboy worker. |
| 4 | + |
| 5 | + Example usage: |
| 6 | + |
| 7 | + defmodule MyApp.Redis do |
| 8 | + use ExredisPoolboy.FunctionsDefinitions, :my_app |
| 9 | + end |
| 10 | + |
| 11 | + MyApp.Redis.sadd("key", 5) |
| 12 | + |
| 13 | + |
| 14 | + All functions imported from Exredis.Api are `defoverridable` |
| 15 | + so you can modify them if you want: |
| 16 | + |
| 17 | + defmodule MyApp.Redis do |
| 18 | + use ExredisPoolboy.FunctionsDefinitions, :my_app |
| 19 | + |
| 20 | + def sadd(_key, nil), do: :error |
| 21 | + def sadd(key, value), do: super(key, value) |
| 22 | + |
| 23 | + def sismember(key, value) do |
| 24 | + case super(key, value) do |
| 25 | + "0" -> false |
| 26 | + "1" -> true |
| 27 | + end |
| 28 | + end |
| 29 | + end |
| 4 30 | """ |
| 5 31 | |
| 6 32 | @doc "Imports all the functions into caller module" |
| @@ -3,7 +3,7 @@ defmodule ExredisPoolboy.Mixfile do | |
| 3 3 | |
| 4 4 | def project do |
| 5 5 | [app: :exredis_poolboy, |
| 6 | - version: "0.2.1", |
| 6 | + version: "0.2.2", |
| 7 7 | description: "Wrapper around exredis using poolboy", |
| 8 8 | elixir: "~> 1.3", |
| 9 9 | build_embedded: Mix.env == :prod, |