redissongo

package module
v0.0.0-...-06eb8d8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 10, 2022 License: Apache-2.0 Imports: 6 Imported by: 0

README

redissongo

Redisson Go语言实现

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseLock

type BaseLock struct {
	// contains filtered or unexported fields
}

BaseLock 锁的模板

func NewBaseLock

func NewBaseLock(client *redis.Client, leaseTime time.Duration, innerLock innerLock) *BaseLock

func (*BaseLock) Lock

func (l *BaseLock) Lock(ctx context.Context) error

Lock 尝试直到获取锁或被关闭

func (*BaseLock) TryLock

func (l *BaseLock) TryLock(ctx context.Context) (bool, error)

TryLock 尝试获取锁或直到被关闭

func (*BaseLock) Unlock

func (l *BaseLock) Unlock(ctx context.Context) error

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client 客户端

func NewClient

func NewClient(config *Config) *Client

func (*Client) GetFairLock

func (c *Client) GetFairLock(resource string) Lock

GetFairLock 获取公平锁

func (*Client) GetLock

func (c *Client) GetLock(resource string) Lock

GetLock 获取可重入锁

type Config

type Config struct {
	Addr      string        // redis地址
	LeaseTime time.Duration // 锁过期时间
	WaitTime  time.Duration // 加锁等待时间
}

Config 配置

type FairLock

type FairLock struct {
	*ReentrantLock
	// contains filtered or unexported fields
}

func NewFairLock

func NewFairLock(client *redis.Client, resource, lockName string, leaseTime, waitTime time.Duration) *FairLock

type Lock

type Lock interface {
	// Lock 获取锁
	Lock(ctx context.Context) error
	// TryLock 尝试获取锁
	TryLock(ctx context.Context) (bool, error)
	// Unlock 释放锁
	Unlock(ctx context.Context) error
}

type ReentrantLock

type ReentrantLock struct {
	// contains filtered or unexported fields
}

func NewReentrantLock

func NewReentrantLock(client *redis.Client, resource, lockName string, leaseTime time.Duration) *ReentrantLock

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL