Learnitweb

Author: Editorial Team

  • Redis Sorted Sets (ZSet)

    Redis Sorted Sets (ZSet) are an extension of regular sets, where each unique item has an associated score. This allows the set to be automatically ordered by score, making it extremely useful for ranking, leaderboards, and priority queues. Key Features of ZSet Common Use Cases Basic Commands 1. Adding Items (ZADD) 2. Checking Set Size…

  • Redis Set Operations: Intersection, Union, and Difference

    Redis sets are unordered collections of unique elements. One of the powerful features of sets is the ability to perform set operations such as intersection, union, and difference, which can be useful for real-world scenarios like filtering candidates based on skills. Example Scenario Imagine an application similar to LinkedIn or Dice: We can model the…

  • Redis Sets

    Redis sets are unordered collections of unique items. They are similar to Java Sets. Sets are useful when you need to: Why Use Sets Instead of Lists? While a list can store multiple items, a set has some advantages: Starting with Redis Sets Step 1: Clear the Database This ensures no old data interferes with…

  • Using Redis Lists as a Stack

    In the previous lecture, we saw how Redis lists can be used like queues (FIFO). In this lecture, we will explore how to use Redis lists as a stack, which is last in, first out (LIFO). Stack Concept Recap A stack follows the principle: Redis lists can easily behave like a stack using the left…

  • Working with Lists in Redis

    In this lecture, we will explore Redis Lists, which are ordered collections of strings. Lists in Redis can be used in many ways, including as queues, stacks, or simply as an ordered collection of elements. What is a Redis List? A Redis list is: Creating a List Redis automatically creates a list if it doesn’t…

  • Working with Hashes in Redis

    So far, we have been exploring how to store simple key-value pairs in Redis. This works well for individual values, but real-world applications often require storing groups of fields that belong to a single object. For example, a user object might have multiple attributes like name, age, city, etc. Redis provides hashes to handle such…

  • Incrementing and Decrementing Values in Redis

    In this lesson, we will learn how to increment (increase) and decrement (decrease) values in Redis. These commands are extremely useful for scenarios where you need to maintain counters, track visits, or update numerical data without manually reading and writing the values every time. Setting Up a Key Before incrementing or decrementing a value, you…

  • Checking for Key Existence in Redis

    In the earlier lessons, we used the KEYS * command to list all the keys in our Redis database. While this approach works fine when you are experimenting or working with a small dataset, it becomes inefficient in real-world scenarios. Let’s now understand why that’s the case, and learn a more efficient way to check…

  • Redis SET Command Options: NX and XX

    In this lecture, we will explore two important conditional options available with the SET command — NX and XX.These options allow you to control when a key should be created or updated, based on whether it already exists in the Redis database. 1. Basic SET Behavior Before we dive into the options, let’s recap the…

  • Redis Expiry and TTL (Time-To-Live)

    In this session, we will explore one of Redis’s most powerful features — key expiration.Expiration allows Redis to automatically remove keys after a specified duration, so you don’t have to delete them manually.This feature is widely used in session management, caching, and temporary data handling in distributed applications. 1. Setting Expiry for Keys Redis allows…