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 {