Documentation ¶
Index ¶
- Variables
- func Hash32(key string) uint32
- func Hash64(key string) uint64
- func IntHash32(key string) int32
- func IntHash64(key string) int64
- func Lock(ctx context.Context, key *Key) error
- func TryLock(ctx context.Context, key *Key) error
- func Uint32ToInt32(u32 uint32) int32
- func Uint64ToInt64(u64 uint64) int64
- type Key
- type Locker
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrAlreadyLocked = errors.New("lock: key already locked") ErrLockOutsideTx = errors.New("lock: lock must be carried out in transaction") )
Functions ¶
func Lock ¶
Lock locks the given key. If multiple operations lock the same key, it will wait for the previous operation to complete. Lock must be run within a transaction context, panics otherwise.
func TryLock ¶
TryLock locks the given key. If multiple operations lock the same key, only the first will succeed. The rest will fail with the error ErrAlreadyLocked. TryLock must be run within a transaction context, panics otherwise.
func Uint32ToInt32 ¶
func Uint64ToInt64 ¶
Types ¶
type Key ¶
type Key struct {
// contains filtered or unexported fields
}
func NewIntKeyPair ¶
func NewStrKeyPair ¶
Click to show internal directories.
Click to hide internal directories.