Documentation ¶
Index ¶
- Variables
- type Client
- func (c *Client) Lock(ctx context.Context, key string, expiration time.Duration, ...) (*Lock, error)
- func (c *Client) SingleflightLock(ctx context.Context, key string, expiration time.Duration, ...) (*Lock, error)
- func (c *Client) TryLock(ctx context.Context, key string, expiration time.Duration) (*Lock, error)
- type FixedIntervalRetry
- type Lock
- type RetryStrategy
Constants ¶
This section is empty.
Variables ¶
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client implements Redis distributed lock
func (*Client) Lock ¶
func (c *Client) Lock(ctx context.Context, key string, expiration time.Duration, timeout time.Duration, retry RetryStrategy) (*Lock, error)
Lock tries to acquire a lock with timeout and retry strategy
func (*Client) SingleflightLock ¶
func (c *Client) SingleflightLock(ctx context.Context, key string, expiration time.Duration, timeout time.Duration, retry RetryStrategy) (*Lock, error)
SingleflightLock is an enhancement of Lock for high concurrency scenarios with singleflight restrictions for concurrency of a key
type FixedIntervalRetry ¶
type Lock ¶
type Lock struct {
// contains filtered or unexported fields
}
Lock is responsible for unlocking and refreshing
func (*Lock) AutoRefresh ¶
AutoRefresh refreshes automatically at interval, timeout specifies the refresh timeout
func (*Lock) AutoRefreshChan ¶
AutoRefreshChan refreshes automatically at interval, timeout specifies the refresh timeout, returns a chan with error
type RetryStrategy ¶
type RetryStrategy interface { // Next determines the time interval for Lock // and whether Lock to retry Next() (time.Duration, bool) }
RetryStrategy is the retry strategy of Lock
Click to show internal directories.
Click to hide internal directories.