https://github.com/jonathan-foucher/spring-boot-redis-lock-example
An example of managing resource lock with a redis
https://github.com/jonathan-foucher/spring-boot-redis-lock-example
java redis-lock spring-boot valkey
Last synced: 6 months ago
JSON representation
An example of managing resource lock with a redis
- Host: GitHub
- URL: https://github.com/jonathan-foucher/spring-boot-redis-lock-example
- Owner: jonathan-foucher
- Created: 2024-09-28T06:58:49.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2025-11-23T13:37:07.000Z (7 months ago)
- Last Synced: 2025-11-23T15:19:12.357Z (7 months ago)
- Topics: java, redis-lock, spring-boot, valkey
- Language: Java
- Homepage:
- Size: 22.5 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## Introduction
This project is an example of Redis / Valkey lock implementation with Spring Boot.
The objective is to create a resource lock on some database entities to prevent them being updated simultaneously by multiple processes.
## Run the project
### Valkey
Valkey is a free open-source project forked from Redis.
If you prefer, you can choose to run Redis instead.
You will need to launch a Valkey instance on your computer before running the project.
You can either install Valkey directly on your machine or run it through Docker :
```
docker run -p 6379:6379 valkey/valkey
```
### Database
Install postgres locally or run it through docker with :
```
docker run -p 5432:5432 -e POSTGRES_DB=redis_lock_db -e POSTGRES_USER=redis_lock -e POSTGRES_PASSWORD=redis_lock postgres
```
### Application
Once Valkey and the postgres database are launched, you can start the Spring Boot project and try it out.
Get all jobs
```
curl --location 'http://localhost:8080/redis-lock-example/jobs'
```
Create a job
```
curl --location --request POST 'http://localhost:8080/redis-lock-example/jobs?name=SOME_JOB'
```
Start a job
```
curl --location --request POST 'http://localhost:8080/redis-lock-example/jobs/3/start'
```