distributed

package
v0.4.28 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2022 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package distributed 分布式.

Locker 基于redis的分布式锁.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrLock   = errors.New("is lock")
	ErrExpire = errors.New("expire time too long")
)

Functions

This section is empty.

Types

type Locker

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

Locker 分布式锁.

func NewLocker

func NewLocker(client redis.Cmdable, times ...time.Duration) *Locker

NewLocker 新建分布式锁. times[0] 锁时间, times[1] 续期间隔.

func (*Locker) Lock

func (p *Locker) Lock(key string, call func() error) error

Lock 锁成功则执行,执行完毕解锁.

Directories

Path Synopsis
nolint
nolint

Jump to

Keyboard shortcuts

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