Skip to content

Instantly share code, notes, and snippets.

View zhaohao19941221's full-sized avatar

coderZhao zhaohao19941221

View GitHub Profile
@zhaohao19941221
zhaohao19941221 / lock.go
Created June 8, 2022 06:25 — forked from bgentry/lock.go
Redis locking in Go with redigo #golang
package main
import (
"github.com/garyburd/redigo/redis"
)
var ErrLockMismatch = errors.New("key is locked with a different secret")
const lockScript = `
local v = redis.call("GET", KEYS[1])