From 8609bf08fb987682acce2333bdde0e6733a1761c Mon Sep 17 00:00:00 2001 From: Mahmud Ridwan Date: Mon, 10 Aug 2020 14:58:57 +0600 Subject: [PATCH] Update README.md --- README.md | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 6c555be..e1bea41 100644 --- a/README.md +++ b/README.md @@ -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" ) @@ -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.