1 Star 0 Fork 0

kade / mcube

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
interface.go 741 Bytes
一键复制 编辑 原始数据 按行查看 历史
kadegolang 提交于 2023-12-13 17:31 . copy
package lock
import (
"context"
"errors"
"time"
"gitee.com/go-kade/mcube/ioc"
)
const (
AppName = "lock"
)
var (
// ErrNotObtained is returned when a lock cannot be obtained.
ErrNotObtained = errors.New("lock: not obtained")
// ErrLockNotHeld is returned when trying to release an inactive lock.
ErrLockNotHeld = errors.New("lock: lock not held")
)
func L() LockFactory {
return ioc.Config().Get(AppName).(*config).lf
}
type LockFactory interface {
New(key string, ttl time.Duration) Lock
}
type Lock interface {
// 锁配置
WithOpt(opt *Options) Lock
// 获取锁
Lock(ctx context.Context) error
// 释放锁
UnLock(ctx context.Context) error
// 刷新锁
Refresh(ctx context.Context, ttl time.Duration) error
}
1
https://gitee.com/go-kade/mcube.git
git@gitee.com:go-kade/mcube.git
go-kade
mcube
mcube
1225d9a674f1

搜索帮助

53164aa7 5694891 3bd8fe86 5694891