Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Вивчайте PubSub | Advanced Features and Security
Introduction to Redis
course content

Зміст курсу

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
PubSub

As shown in the illustration, publishers send messages to specific channels, and subscribers listening to those channels receive the corresponding notifications.

Practical Use Case

Subscription System

Imagine an e-commerce platform where users need to be notified about the status of their orders. As the order status changes (Processing, Shipped, Delivered), users must receive timely updates. Redis subscriptions and notifications can be used to implement this system.

Subscribing to a Channel

Each user subscribes to a unique channel, typically named after their order ID. This ensures that each user receives notifications only about their specific order.

Client 1 subscribes to the channel order-123:

After subscribing to the order-123 channel, the client listens for messages on that channel. Whenever a message is sent to this channel, the client receives it immediately.

Publishing an Order Status Update

When the status of User 1's order changes (e.g., the order is shipped), the system publishes a message to the order-123 channel. This message is delivered to all clients subscribed to the channel.

The system publishes the following update for User 1:

Client 1, subscribed to order-123, receives the following message:

Unsubscribing from a Channel

If a client no longer wants to receive updates, they can unsubscribe from the channel using the UNSUBSCRIBE command.

Client 1 unsubscribes from order-123:

After unsubscribing, Client 1 will no longer receive notifications about their order status unless they subscribe to the channel again.

This example demonstrates how Redis subscriptions and notifications can be used to create real-time messaging systems. Redis ensures timely delivery of notifications and simplifies communication within the system.

1. What does the SUBSCRIBE command in Redis do?

2. Which command is used to unsubscribe from a Redis channel?

What does the `SUBSCRIBE` command in Redis do?

What does the SUBSCRIBE command in Redis do?

Виберіть правильну відповідь

Which command is used to unsubscribe from a Redis channel?

Which command is used to unsubscribe from a Redis channel?

Виберіть правильну відповідь

Все було зрозуміло?

Як ми можемо покращити це?

Дякуємо за ваш відгук!

Секція 4. Розділ 3
We're sorry to hear that something went wrong. What happened?
some-alt