Install & Compatibility
Where this runs
No compatibility data collected yet for this library.
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
redsync
✓ github.com/go-redsync/redsync
Acquire a distributed lock with Redis
package main
import (
"fmt"
"github.com/go-redsync/redsync"
"github.com/gomodule/redigo/redis"
)
func main() {
pool := &redis.Pool{Dial: func() (redis.Conn, error) { return redis.Dial("tcp", ":6379") }}
rs := redsync.New([]redsync.Pool{pool})
mutex := rs.NewMutex("my-lock")
if err := mutex.Lock(); err != nil {
fmt.Println("Lock failed")
} else {
fmt.Println("Lock acquired")
mutex.Unlock()
}
}
Debug
Known issues
No known issues recorded.
Upgrade
Version history
1.4.2latest on pkg.go.dev
Audit
Dependencies
No dependency data recorded yet.