Documentation ¶
Index ¶
Constants ¶
View Source
const ( // DefaultRetryCount is the max retry times for lock acquire DefaultRetryCount = 10 // DefaultRetryDelay is upper wait time in millisecond for lock acquire retry DefaultRetryDelay = 200 // ClockDriftFactor is clock drift factor, more information refers to doc ClockDriftFactor = 0.01 // UnlockScript is redis lua script to release a lock UnlockScript = `` /* 155-byte string literal not displayed */ )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type KVCache ¶ added in v1.1.0
type KVCache interface { // Set sets the key value with its expiry in milliseconds Set(key, val string, expiry int64) *LockElem // Get queries LockElem from given key Get(key string) *LockElem // Delete removes the LockElem with given key from storage Delete(key string) // Size returns element count in kv storage Size() int // GC cleans the expired LockElem stored in storage GC() }
KVCache defines interface for redlock key value storage
type LockElem ¶ added in v1.1.0
type LockElem struct {
// contains filtered or unexported fields
}
LockElem keeps a lock element
type RedClient ¶
type RedClient struct {
// contains filtered or unexported fields
}
RedClient holds client to redis
type RedLock ¶
type RedLock struct {
// contains filtered or unexported fields
}
RedLock holds the redis lock
func (*RedLock) SetRetryCount ¶
SetRetryCount sets acquire lock retry count
func (*RedLock) SetRetryDelay ¶
SetRetryDelay sets acquire lock retry max internal in millisecond
type SimpleCache ¶ added in v1.1.0
type SimpleCache struct {
// contains filtered or unexported fields
}
SimpleCache is the most negative implementation of KVCache interface
func NewSimpleCache ¶ added in v1.1.0
func NewSimpleCache() *SimpleCache
NewSimpleCache creates a new SimpleCache object
func (*SimpleCache) Delete ¶ added in v1.1.0
func (sc *SimpleCache) Delete(key string)
Delete implements KVCache.Delete
func (*SimpleCache) Get ¶ added in v1.1.0
func (sc *SimpleCache) Get(key string) *LockElem
Get implements KVCache.Get
func (*SimpleCache) Set ¶ added in v1.1.0
func (sc *SimpleCache) Set(key, val string, expiry int64) *LockElem
Set implements KVCache.Set
func (*SimpleCache) Size ¶ added in v1.1.1
func (sc *SimpleCache) Size() int
Size implements KVCache.Size
Click to show internal directories.
Click to hide internal directories.