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.
go mod download
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!