Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
hjr265 committed Aug 10, 2020
1 parent 2d90f66 commit 8609bf0
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ package main

import (
"github.com/go-redsync/redsync"
"github.com/go-redsync/redsync/v3/redis"
"github.com/go-redsync/redsync/v3/redis/redigo"
"github.com/gomodule/redigo/redis"
)

Expand All @@ -48,15 +50,17 @@ func main() {
if _, err := redisPool.Get().Do("PING"); err != nil {
panic(err)
}


// Create an instance of redisync to be used to obtain a mutual exclusion
// lock.
rs := redsync.New([]redsync.Pool{pool})
pool := goredis.NewGoredisPool(client) // or, pool := redigo.NewRedigoPool(...)
rs := redsync.New([]redis.Pool{pool})

// Obtain a new mutex by using the same name for all instances wanting the
// same lock.
mutexName := "my-global-mutex"
mutex := rs.NewMutex(mutexName)
mutexname := "my-global-mutex"
mutex := rs.NewMutex(mutexname)

// Obtain a lock for our given mutex. After this is successful, no one else
// can obtain the same lock (the same mutex name) until we unlock it.
Expand Down

0 comments on commit 8609bf0

Please sign in to comment.