Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrNotObtained is returned when a lock cannot be obtained. ErrNotObtained = errors.New("redislock: not obtained") // ErrLockNotHeld is returned when trying to release an inactive lock. ErrLockNotHeld = errors.New("redislock: lock not held") )
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client wraps a redis client.
func New ¶
func New(client RedisClient) *Client
New creates a new Client instance with a custom namespace.
type Lock ¶
type Lock struct {
// contains filtered or unexported fields
}
Lock represents an ontained, distributed lock.
func (*Lock) Refresh ¶
Refresh extends the lock with a new TTL. May return ErrNotObtained if refresh is unsuccessful.
type Options ¶
type Options struct { // The number of time the acquisition of a lock will be retried. // Default: 0 = do not retry RetryCount int // RetryBackoff is the amount of time to wait between retries. // Default: 100ms RetryBackoff time.Duration // Metadata string is appended to the lock token. Metadata string // Optional context for Obtain timeout and cancellation control. Context context.Context }
Options describe the options for the lock
type RedisClient ¶
type RedisClient interface { SetNX(key string, value interface{}, expiration time.Duration) *redis.BoolCmd Eval(script string, keys []string, args ...interface{}) *redis.Cmd EvalSha(sha1 string, keys []string, args ...interface{}) *redis.Cmd ScriptExists(scripts ...string) *redis.BoolSliceCmd ScriptLoad(script string) *redis.StringCmd }
RedisClient is a minimal client interface.
Click to show internal directories.
Click to hide internal directories.