POC made in Java to learn how to do a project using Redis and learn the basics of this technology. Also used Postgres to handle all the data.
Of course, that cache would only be needed in operations that would take a lot of time to gather from databases, for example. But as told, this was only an example to understand how it works.
In order to test this the procedure was the following:
- When starting up the project - by making
make run
in the terminal - the Postgres database starts, alongside redis and the app itself; - Then there are a couple of endpoints, like getting a user by id (
GET /users/{id}
), updating a user (PUT /users/{id}
), and delete a user (DELETE /users/{id}
) that make alterations to the cache;
After starting the whole project and making the endpoint calls that are referred, you can make the following:
- Go to your redis container (Check the container id by doing
docker ps
and then make
docker exec -it <docker container id> bash
); - Once inside the container you can start the redis client (run
redis-cli
); - And last you can check all the keys and values you want by making
keys '*'
and
get users::{userid}
and you will see the respective objects and follow the changes when calling the endpoints;
To run it you can simply make the following command:
make run
and to stop the application:
make stop