Documentation ¶
Index ¶
- Variables
- type Client
- func (c *Client) Lock(ctx context.Context, key string, expiration, timeout time.Duration, ...) (*Lock, error)
- func (c *Client) SingleFlightLock(ctx context.Context, key string, expiration, timeout time.Duration, ...) (*Lock, error)
- func (c *Client) TryLock(ctx context.Context, key string, expiration time.Duration) (*Lock, error)
- type FixIntervalRetry
- type Lock
- type RetryStrategy
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrLockFailed = errors.New("lock failed") ErrLockNotHold = errors.New("not hold current lock") )
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a client held redis client
func (*Client) Lock ¶
func (c *Client) Lock(ctx context.Context, key string, expiration, timeout time.Duration, retry RetryStrategy) (*Lock, error)
Lock locks
type FixIntervalRetry ¶
type FixIntervalRetry struct { Interval time.Duration // retry interval Max int // max retry times // contains filtered or unexported fields }
FixIntervalRetry is a fix interval retry strategy
type Lock ¶
type Lock struct {
// contains filtered or unexported fields
}
Lock is a lock created after client locks successfully
func (*Lock) AutoRefresh ¶
AutoRefresh always refreshes lock's expiration automatically
type RetryStrategy ¶
type RetryStrategy interface { // Next // first return means the interval of the next retry // second return means need to retry or not Next() (time.Duration, bool) }
RetryStrategy defines retry strategy
Click to show internal directories.
Click to hide internal directories.