GithubHelp home page GithubHelp logo

milosdiwanee / redix_pool Goto Github PK

View Code? Open in Web Editor NEW

This project forked from legendsoflearning/redix_pool

0.0 0.0 0.0 39 KB

Redix + Poolboy, suports multiple pools

License: MIT License

Elixir 100.00%

redix_pool's Introduction

RedixPool

Redis pooling built on redix and poolboy.

Installation

def deps do
  [{:redix_pool, github: "LegendsOfLearning/redix_pool", branch: "master"}]
end

Configuration

RedixPool supports both poolboy configuration as well as Redix configurations.

# myapp/config/config.exs
use Mix.Config

config :redix_pool, :redix_default
  redis_url: "redis://localhost:6379",
  pool_size: {:system, "POOL_SIZE"}, # System.get_env("POOL_SIZE") will be executed at runtime
  pool_max_overflow: 1,
  redix_opts: [
    sync_connect: true,
  ]

# A pool named "sessions_rw"
config :redix_pool, :sessions_rw,
  redis_url: {:system, "SESSION_READ_REDIS_URL"}, # Defaults to redis://localhost:6379/0
  redix_opts: [
    timeout: 3000,
    backoff_initial: 1000,
    backoff_max: 10000,
    sock_opts: [:verify, :verify_none]
  ], # See: https://hexdocs.pm/redix/0.10.2/Redix.html#start_link/1-options
  pool_size: {:system, "SESSION_READ_POOL_SIZE", 8}
  pool_max_overflow: {:system, "SESSION_READ_MAX_OVERFLOW", 16},
  timeout: 10000

If you want to to use this as a part of a supervision tree:

Basic Usage

RedixPool supports command/3 and pipeline/3 (and their bang variants), which are just like the Redix command/3 and pipeline/3 functions, except RedixPool handles the connection for you.

This means using command is as simple as:

alias RedixPool, as: Redis

Redis.command(:redix_default, ["FLUSHDB"])
#=> {:ok, "OK"}

Redis.command(:redix_default, ["SET", "foo", "bar"])
#=> {:ok, "OK"}

Redis.command(:redix_default, ["GET", "foo"])
#=> {:ok, "bar"}

Testing

Currently, the tests assume you have an instance of Redis running locally at localhost:6379.

On OSX, Redis can be installed easily with brew:

brew install redis

Once you have Redis running, simply run mix test.

Documentation can be generated with ExDoc and published on HexDocs. Once published, the docs can be found at https://hexdocs.pm/redix_pool.

redix_pool's People

Contributors

hosh avatar connorjacobsen avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.