locks

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BlockPrefix = "blocks"
)

Variables

This section is empty.

Functions

func Failed

func Failed(err error) bool

func LockKey

func LockKey(k string) string

Types

type Failure

type Failure struct{}
var ErrLock *Failure

func (*Failure) Error

func (err *Failure) Error() string

type Lock

type Lock interface {
	Lock(ctx context.Context) (bool, error)
	UnLock(ctx context.Context)
	Locked(ctx context.Context) (bool, error)
}

Lock ロックを行うためのインターフェース

type RedisLock

type RedisLock struct {
	Key      string        // ロックするキー
	Duration time.Duration // ロックする期間
}

RedisLock Redisを使ってロック

func (*RedisLock) Lock

func (l *RedisLock) Lock(ctx context.Context) (bool, error)

func (*RedisLock) Locked

func (l *RedisLock) Locked(ctx context.Context) (bool, error)

func (*RedisLock) String

func (l *RedisLock) String() string

func (*RedisLock) UnLock

func (l *RedisLock) UnLock(ctx context.Context)

Jump to

Keyboard shortcuts

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