keylock

package
v1.20.5 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2019 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type KeyLock

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

KeyLock is a simple implementation of key based locks with ttl's on them

func NewKeyLock

func NewKeyLock() *KeyLock

func (*KeyLock) Lock

func (kl *KeyLock) Lock(key interface{}, timeout time.Duration, ttl time.Duration) int64

Lock attempts to lock the specified key for the specified duration, expiring after ttl if it fails to grab the key after timeout it will return -1, it will return a lock handle otherwise that you use to unlock it with. this is to protect against you unlocking it after the ttl expired when something else is holding it

func (*KeyLock) Unlock

func (kl *KeyLock) Unlock(key interface{}, handle int64)

Jump to

Keyboard shortcuts

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