Skip to content

Files

Latest commit

 

History

History
28 lines (20 loc) · 480 Bytes

README.md

File metadata and controls

28 lines (20 loc) · 480 Bytes

redislock

Pessimistic locking for Go using Redis.

Installation

go get -u github.com/atomic-labs/redislock

Documentation

http://godoc.org/github.com/atomic-labs/redislock

Example

lock, ok, err := redislock.TryLock(conn, "user:123")
if err != nil {
	log.Fatal("Error while attempting lock")
}
if !ok {
	// User is in use - return to avoid duplicate work, race conditions, etc.
	return
}
defer lock.Unlock()

// Do something with the user.