Documentation ¶
Index ¶
- func SetRenewExpirationOption(option bool)
- type ReplicaLock
- func (RepLock *ReplicaLock) ForceUnlock() bool
- func (RepLock *ReplicaLock) Lock(timeout int64, leaseTime int64, TimeUnit string) error
- func (RepLock *ReplicaLock) SetRawKeyName(RawKeyName string)
- func (RepLock *ReplicaLock) TryLock(waitTime int64, timeout int64, leaseTime int64, TimeUnit string) (bool, error)
- func (RepLock *ReplicaLock) Unlock()
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SetRenewExpirationOption ¶
func SetRenewExpirationOption(option bool)
SetRenewExpirationOption Enabled renewExpiration if 'option' is true. Disabled renewExpiration if 'option' is false.
Types ¶
type ReplicaLock ¶
type ReplicaLock struct {
// contains filtered or unexported fields
}
func NewWithRawKeyName ¶
func NewWithRawKeyName(Conn redis.Conn, RawKeyName string) (ReplicaLock, error)
NewWithRawKeyName return a ReplicaLock, this allows the user to set the key name for a more granular locking.
func (*ReplicaLock) ForceUnlock ¶
func (RepLock *ReplicaLock) ForceUnlock() bool
ForceUnlock forces the deletion of the key (if the key exists), whether it has a lock or not.Please be aware of the risks.
func (*ReplicaLock) Lock ¶
func (RepLock *ReplicaLock) Lock(timeout int64, leaseTime int64, TimeUnit string) error
Lock will keep trying to acquire the lock until it succeeds. 'timeout' is the maximum time we wait for all replicas to finish synchronizing. 'leaseTime' is the existence time of the lock. TimeUnit is a unit of time for 'waitTime','timeout','leaseTime'. Note that we will convert the input parameters to make it in the legal range.
func (*ReplicaLock) SetRawKeyName ¶
func (RepLock *ReplicaLock) SetRawKeyName(RawKeyName string)
SetRawKeyName allow users to change the name after creating a lock, or to use the same ReplicaLock again, but lock other things.
func (*ReplicaLock) TryLock ¶
func (RepLock *ReplicaLock) TryLock(waitTime int64, timeout int64, leaseTime int64, TimeUnit string) (bool, error)
TryLock attempt to acquire the lock during the 'waitTime' time. 'timeout' is the maximum time we wait for all replicas to finish synchronizing. 'leaseTime' is the existence time of the lock. TimeUnit is a unit of time for 'waitTime','timeout','leaseTime'. the bool returned by Trylock tells the user whether the lock was successful(true) or not(false). Note that we will convert the input parameters to make it in the legal range.
func (*ReplicaLock) Unlock ¶
func (RepLock *ReplicaLock) Unlock()