From 20638f2dff0ca555a6e3fc0270cb51b35af4a959 Mon Sep 17 00:00:00 2001 From: Danilo Pantani Date: Wed, 16 Sep 2020 19:06:13 -0300 Subject: [PATCH] add datavase index parameter --- README.md | 2 +- redis.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 8ed2b51..5960446 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Initialize the database: ```go import "github.com/Pantani/redis" -cache := redis.New("localhost:6379‎", "password") +cache := redis.New("localhost:6379", "password", 0) if err != nil { panic("Cannot initialize the redis storage") } diff --git a/redis.go b/redis.go index ed4c5f9..d61e983 100644 --- a/redis.go +++ b/redis.go @@ -13,11 +13,11 @@ type Redis struct { } // New returns a new database connection and an error if occurs. -func New(host, password string) (*Redis, error) { +func New(host, password string, dbIndex int) (*Redis, error) { rdb := redis.NewClient(&redis.Options{ Addr: host, Password: password, - DB: 0, + DB: dbIndex, }) _, err := rdb.Ping(context.Background()).Result() if err != nil {