Documentation ¶ Index ¶ Constants func TryLock(ctx context.Context, conn *connCli, key string, ex, lease int) (string, context.CancelFunc, error) func UnLock(conn *connCli, cancelFunc context.CancelFunc, key, leaseId string) (bool, error) type LockError func (le LockError) Error() string func (le LockError) GetCode() int Constants ¶ View Source const ( InternalCodeFailed = 999 // 未取到锁 InternalCodeErr = 998 // 连接异常 InternalCodeLockNotOwn = 997 // 不是自己的锁 InternalCodeExLtLease = 996 // 有效期必须大于续租+minInterval时间 ) Variables ¶ This section is empty. Functions ¶ func TryLock ¶ func TryLock(ctx context.Context, conn *connCli, key string, ex, lease int) (string, context.CancelFunc, error) func UnLock ¶ func UnLock(conn *connCli, cancelFunc context.CancelFunc, key, leaseId string) (bool, error) UnLock 取消分布式锁 Types ¶ type LockError ¶ type LockError struct { Code int Msg string } func (LockError) Error ¶ func (le LockError) Error() string func (LockError) GetCode ¶ func (le LockError) GetCode() int Source Files ¶ View all Source files redis_try_lock.go Click to show internal directories. Click to hide internal directories.