https://github.com/ashkan-maleki/go-r-api-idempotent
Idempotent APIs: Avoid Duplicate Requests with Golang and Redis
https://github.com/ashkan-maleki/go-r-api-idempotent
docker docker-compose go gofiber golang gorm postgres redis
Last synced: 3 months ago
JSON representation
Idempotent APIs: Avoid Duplicate Requests with Golang and Redis
- Host: GitHub
- URL: https://github.com/ashkan-maleki/go-r-api-idempotent
- Owner: ashkan-maleki
- License: mit
- Created: 2023-07-13T05:51:35.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2023-07-16T06:32:27.000Z (almost 3 years ago)
- Last Synced: 2025-03-04T23:43:48.983Z (over 1 year ago)
- Topics: docker, docker-compose, go, gofiber, golang, gorm, postgres, redis
- Language: Go
- Homepage:
- Size: 95.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Idempotent APIs: Avoid Duplicate Requests with Golang and Redis
## Process:
### First API Call
1) Make a POST request to the "shipping/order" API endpoint.
2) The specified "order_id" is checked in the Redis. If it exists, the object is sent to the user.
3) if it doesn't exist, the service stores the new object in Postgres and Redis after 3 seconds (this 3 seconds delay is
deliberately used to demonstrate the process).
### Second API Call
1) Make a POST request to the "shipping/order" API endpoint with the same "order_id" parameter.
2) The service responds and returns the object instantly.
# Requirements
1) Golang, 2) Redis, 3) Postgres, 4) Docker, 5) Docker Compose, 6) Make, 7) Gofiber