Skip to content

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

Notifications You must be signed in to change notification settings

congleetea/eredis_pool

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

62 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

eredis_pool

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

eredis: github.com/wooga/eredis

poolboy: github.com/congleetea/poolboy (fork from github.com/comtihon/poolboy)

Setup

$ git clone git://github.com/congleetea/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, [
          {pools, [
                   {default, [
                              {size, 10},
                              {max_overflow, 20}
                             ], [] }
                  ]}
        ]}
 ]}.

add new pools.

{env, [
        {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

cd eredis_pool && erl -pa ebin -pa ./deps/*/ebin > application:ensure_all_started(eredis_pool).

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

About

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

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Erlang 97.4%
  • Makefile 2.6%