Versions in this module Expand all Collapse all v0 v0.0.3 Nov 9, 2023 v0.0.2 Nov 18, 2022 Changes in this version + var ErrFailedToPreemptLock = errors.New("rlock: 抢锁失败") + var ErrLockNotHold = errors.New("rlock: 未持有锁") + type Client struct + func NewClient(client redis.Cmdable) *Client + func (c *Client) Lock(ctx context.Context, key string, expiration time.Duration, retry RetryStrategy, ...) (*Lock, error) + func (c *Client) SingleflightLock(ctx context.Context, key string, expiration time.Duration, retry RetryStrategy, ...) (*Lock, error) + func (c *Client) TryLock(ctx context.Context, key string, expiration time.Duration) (*Lock, error) + type FixIntervalRetry struct + Interval time.Duration + Max int + func (f *FixIntervalRetry) Next() (time.Duration, bool) + type Lock struct + func (l *Lock) AutoRefresh(interval time.Duration, timeout time.Duration) error + func (l *Lock) Refresh(ctx context.Context) error + func (l *Lock) Unlock(ctx context.Context) error + type RetryStrategy interface + Next func() (time.Duration, bool)