Giter VIP home page Giter VIP logo

eredis_pool's Introduction

eredis_pool

eredis_pool is Pool of Redis clients, using eredis and poolboy.

eredis: github.com/wooga/eredis

poolboy: github.com/devinus/poolboy

Setup

$ git clone git://github.com/hiroeorz/eredis_pool.git
$ cd eredis_pool
$ make get-deps
$ make

Testing

$ make test

Settings

edit src/eredis_pool.app.src

{application, eredis_pool,
 [
  {description, ""},
  {vsn, "1"},
  {registered, []},
  {applications, [
                  kernel,
                  stdlib
                 ]},
  {mod, { eredis_pool_app, []}},
  {env, [
          {global_or_local, local},
          {pools, [
                   {default, [
                              {size, 10},
                              {max_overflow, 20}
                             ], [] }
                  ]}
        ]}
 ]}.

add new pools.

{env, [
        {global_or_local, local},
        {pools, [
                 {default, [
                            {size, 10},
                            {max_overflow, 20}
                           ], []},
                 {pool1, [
                            {size, 30},
                            {max_overflow, 20}
                           ], [
                            {host, "127.0.0.1"},
                            {port, 6379}
                           ]},
                 {pool2, [
                            {size, 20},
                            {max_overflow, 20}
                         ], [
                            {host, "127.0.0.1"},
                            {port, 6379},
                            {database, "user_db"},
                            {password, "abc"},
                            {reconnect_sleep, 100}
                           ]}
                ]}
      ]}

Examples

application start.

eredis_pool:start().
ok

key-value set and get

eredis_pool:q({global, dbsrv}, ["SET", "foo", "bar"]).
{ok,<<"OK">>}

eredis_pool:q({global, dbsrv}, ["GET", "foo"]).       
{ok,<<"bar">>}

Redis Pipeline

Pipeline = [["SET", a, "1"],
     ["LPUSH", b, "3"],
     ["LPUSH", b, "2"]].
eredis_pool:qp({global,dbsrv}, Pipeline).

create new pool with default settings.

eredis_pool:create_pool(pool1, 10).
{ok,<0.64.0>}

and omissible argments(host, port, database, password reconnect_sleep).

eredis_pool:create_pool(pool1, 10, "127.0.0.1", 6379, 1, "abc", 100).
{ok,<0.64.0>}

using new pool

eredis_pool:q(pool1, ["GET", "foo"]).
{ok,<<"bar">>}

delete pool

eredis_pool:delete_pool(pool1).    
ok

Other commands is here. redis.io/commands

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.