Categorygithub.com/eininst/rlock
modulepackage
0.0.0-20241223182021-e02095f7303d
Repository: https://github.com/eininst/rlock.git
Documentation: pkg.go.dev

# README

Rlock

Go Reference License

Implementation of redis lock

⚙️ Installation

go get -u github.com/eininst/rlock

⚡ Quickstart

func init(){
    rlock.SetDefault(getRedis())
}

func main() {
    ok, cancel := rlock.Acquire("lock_name_test", time.Second*10)
    defer cancel()
    if ok {
        fmt.Println("my is safe")
    }
}

👀 New a Instance

func main() {
    lk := rlock.New(getRedis())
    
    ok, cancel := lk.Acquire("lock_name_test", time.Second*10)
    defer cancel()
    if ok {
        fmt.Println("my is safe")
    }
}

See examples

License

MIT

# Packages

No description provided by the author

# Functions

6) 方便使用的全局函数.
5) 创建新的 Rlock 实例,并在首次调用时加载 Lua 脚本.
4) 全局方法 SetDefault,可设置单例锁实例.
No description provided by the author

# Structs

No description provided by the author
3) Rlock 相关结构.
用于记录上下文/键值.

# Type aliases

解锁函数类型.