Skip to content

Commit

Permalink
Merge pull request #4 from Pantani/pantani/add-db-index
Browse files Browse the repository at this point in the history
add database index parameter
Pantani authored Sep 16, 2020

Verified

This commit was signed with the committer’s verified signature.
2 parents 2b241a5 + 20638f2 commit 4dd6e6c
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -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")
}
4 changes: 2 additions & 2 deletions redis.go
Original file line number Diff line number Diff line change
@@ -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 {

0 comments on commit 4dd6e6c

Please sign in to comment.