Skip to content

Instantly share code, notes, and snippets.

@CalyCherkaoui
Created January 7, 2023 18:00
Show Gist options
  • Save CalyCherkaoui/55a17980fa9e0f854c537856eefec82c to your computer and use it in GitHub Desktop.
Save CalyCherkaoui/55a17980fa9e0f854c537856eefec82c to your computer and use it in GitHub Desktop.
Redis can be used in a variety of scenarios
@CalyCherkaoui
Copy link
Author

CalyCherkaoui commented Jan 7, 2023

How can Redis be used?

There is more to Redis than just caching.
.
Redis can be used in a variety of scenarios:
Session
We can use Redis to share user session data among different services.

Cache
We can use Redis to cache objects or pages, especially for hotspot data.

Distributed lock
We can use a Redis string to acquire locks among distributed services.

Counter
We can count how many likes or how many reads for articles.

Rate limiter
We can apply a rate limiter for certain user IPs.

Global ID generator
We can use Redis Int for global ID.

Shopping cart
We can use Redis Hash to represent key-value pairs in a shopping cart.

Calculate user retention
We can use Bitmap to represent the user login daily and calculate user retention.

Message queue
We can use List for a message queue.

Ranking
We can use ZSet to sort the articles.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment