Skip to content

jdboisvert/redis-distributed-locks

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Redis Distributed Locks Example in Go

Just a simple example highlighting how to use distributed locks in Redis with Go. If you want to learn more about distributed locks and how they work I recommend reading this article and I wrote a blog post about it too.

Getting Started

Prerequisites

Installing

go mod download

Running

go run main.go

Example output:

First lock acquired!
Could not get a second lock which is as expected this is where you would force the request out.
Still could not get the third lock since the first lock is still set.
First lock released!
Forth Lock acquired!
Forth Lock released!