lock

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2021 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultAcquireTimeout int64 = 100       // 获取锁的timeout时间,默认100ms
	DefaultLockTimeout    int64 = 10 * 1000 // 锁过期时间,默认10s

	RetryInterval time.Duration = 1        // 获取锁失败后,重试间隔,默认1ms
	LockPrefix                  = "stlock" // 锁前缀
)

Variables

This section is empty.

Functions

func AcquireLock

func AcquireLock(conn redis.Conn, lockName string, acquireTimeout, lockTimeout int64) (string, error)

获取分布式锁

func DialRedis

func DialRedis(host, password string, port, db int) (*redis.Pool, error)

连接redis,返回连接池

func ReleaseLock

func ReleaseLock(conn redis.Conn, lockName, identifier string) error

释放分布式锁

Types

This section is empty.

Jump to

Keyboard shortcuts

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