Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var DefaultWatchDogTimeout = 30 * time.Second
DefaultWatchDogTimeout The default watchdog timeout, the watchdog will go every 1/3 of the DefaultWatchDogTimeout to renew the lock held by the current thread.
var ( // ErrObtainLockTimeout indicates that Lock cannot be acquired within waitTime ErrObtainLockTimeout = errors.New("obtained lock timeout") )
Functions ¶
This section is empty.
Types ¶
type GoRedisson ¶
type GoRedisson struct {
// contains filtered or unexported fields
}
GoRedisson is a redisson client.
func NewGoRedisson ¶
func NewGoRedisson(redisClient *redis.Client, opts ...OptionFunc) *GoRedisson
NewGoRedisson returns a new GoRedisson instance.
func (*GoRedisson) GetLock ¶
func (g *GoRedisson) GetLock(key string) Lock
GetLock returns a Lock named "key" which can be used to lock and unlock the resource "key". A Lock can be copied after first use, but most of the time it is advisable to keep instances of Lock.
func (*GoRedisson) GetMutex ¶ added in v1.1.2
func (g *GoRedisson) GetMutex(key string) Lock
GetMutex returns a Mutex named "key" which can be used to lock and unlock the resource "key". A Mutex can be copied after first use, but most of the time it is advisable to keep instances of Lock. the difference between Mutex and Lock is that Mutex can't be locked by any thread twice.
func (*GoRedisson) GetReadWriteLock ¶
func (g *GoRedisson) GetReadWriteLock(key string) ReadWriteLock
GetReadWriteLock returns a ReadWriteLock named "key" which can be used to lock and unlock the resource "key" when reading or writing. A ReadWriteLock can be copied after first use, but most of the time it is advisable to keep instances of ReadWriteLock.
type Lock ¶
type Lock interface { Lock() error Unlock() error LockContext(context.Context) error UnlockContext(context.Context) error }
A Lock represents an object that can be locked and unlocked.
type OptionFunc ¶
type OptionFunc func(g *GoRedisson)
OptionFunc is a function that can be used to configure a GoRedisson instance.
func WithWatchDogTimeout ¶
func WithWatchDogTimeout(t time.Duration) OptionFunc
WithWatchDogTimeout sets the timeout for the watchdog.
type ReadWriteLock ¶
ReadWriteLock is a interface for read/write lock