Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Aprende Challenge: INCR and DECR | The Essential Redis Commands
Introduction to Redis
course content

Contenido del Curso

Introduction to Redis

Introduction to Redis

1. Redis Fundamentals
2. The Essential Redis Commands
3. Data Types in Redis
4. Advanced Features and Security
5. Caching with Redis and Spring Boot

book
Challenge: INCR and DECR

You are working with a platform where users can like or dislike various posts. Each post has a unique identifier, such as post:1, post:2, post:3.

The task is to build a system to track reactions on multiple posts by randomly adding likes and dislikes, and then displaying the total count of reactions for each post.

  1. Create 3 posts, each with two counters: one for likes and one for dislikes. For example: post:1:likes, post:1:dislikes, and so on;

  2. Use the INCR or INCRBY command to add likes and dislikes to each post. Add 3 likes and 2 dislikes to post:1, and 5 likes and 1 dislike to post:2;

  3. Use the DECR or DECRBY command to decrease reactions for some posts. Remove 1 like from post:1 and 2 dislikes from post:2;

  4. Use the GET command to retrieve the current number of likes and dislikes for each post.

The expected result should look like this:

Create counters for likes and dislikes for each post:

Add 3 likes and 2 dislikes to post:1:

Add 5 likes and 1 dislike to post:2:

Remove 1 like from post:1 and 2 dislikes from post:2:

Retrieve the current number of likes and dislikes for each post:

¿Todo estuvo claro?

¿Cómo podemos mejorarlo?

¡Gracias por tus comentarios!

Sección 2. Capítulo 6
We're sorry to hear that something went wrong. What happened?
some-alt