[v] прошла вся цепочка вызова

This commit is contained in:
Leonid Nikolaev committed 2023-01-27 11:42:17 +03:00
1 parent 02f37d7426
commit 7c1747cb13
14 files changed
+214 -30

No files matched your search

+33
View File
@@ -0,0 +1,33 @@
package main
import (
"fmt"
"time"
goredislib "github.com/go-redis/redis/v8"
"github.com/go-redsync/redsync/v4"
"github.com/go-redsync/redsync/v4/redis/goredis/v8"
)
func main() {
client := goredislib.NewClient(&goredislib.Options{
Addr: "localhost:6379",
})
pool := goredis.NewPool(client) // or, pool := redigo.NewPool(...)
rs := redsync.New(pool)
mutexname := "my-global-mutex"
mutex := rs.NewMutex(mutexname, redsync.WithExpiry(time.Minute))
if err := mutex.Lock(); err != nil {
panic(err)
}
var a string
fmt.Scanf("%s", &a)
if ok, err := mutex.Unlock(); !ok || err != nil {
panic("unlock failed")
}
}