代码拉取完成,页面将自动刷新
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
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。