Learnitweb

Category: redis

  • Redis Transactions: Ensuring Atomic Operations

    In this lecture, we will learn how to perform atomic transactions in Redis, using a reactive approach. Transactions help ensure that a series of operations either all succeed or all fail, which is crucial for scenarios like banking or balance transfers. 1. Problem Overview 2. Non-Transactional Example Setup: Simulated Error Scenario 3. Transactional Approach Step…

  • Efficient Batch Operations in Redis

    In this lecture, we will discuss how to efficiently perform high-volume data operations in Redis using batch processing. This approach reduces network overhead, improves performance, and allows you to handle large numbers of operations quickly. 1. Problem Overview 2. Basic Idea of Batch Operations 3. Setting Up the Batch 4. Adding Items to the Batch…

  • Pattern-Based Subscriptions in Pub/Sub

    In this lecture, we will explore how subscribers can listen to multiple channels using pattern-based subscriptions instead of subscribing to exact topic names. This allows greater flexibility and selective listening in real-time messaging systems. 1. Exact Topic vs Pattern-Based Subscriptions Exact Topic Subscription: Pattern-Based Subscription: 2. Example Use Case This allows one subscriber to filter…

  • Publish-Subscribe Messaging (Pub/Sub)

    In this lecture, we will explore Pub/Sub messaging, its behavior, and how it differs from traditional message queues. We will also demonstrate a simple implementation with producers and subscribers. 1. Pub/Sub vs Message Queue Message Queue: Key Point: No duplicate processing occurs. If a message is taken by one consumer, it is not available to…

  • HyperLogLog in Java/Redis: Estimating Unique Counts Efficiently

    In this lecture, we will explore HyperLogLog, a probabilistic data structure that is highly useful for counting unique elements in high-volume datasets without consuming a lot of memory. 1. Problem Scenario Imagine you are running a high-traffic application with multiple microservices. Some of the common business requirements might be: For business decisions, exact numbers are…

  • Using Redisson Lists as a Message Queue (Producer-Consumer Pattern)

    Redisson supports reactive and blocking lists/deques, which can be leveraged to implement a message queue. This allows multiple producers and consumers to communicate asynchronously, similar to a microservice messaging system. In this tutorial, we will cover: 1. Setting Up the Message Queue We will use a blocking deque to simulate a message queue. Explanation: 2.…

  • Using Redisson Reactive Lists as Queue and Stack

    Redisson provides reactive implementations of Redis data structures. While RListReactive behaves like a standard list, we can use additional methods to make it behave like a queue (FIFO) or stack (LIFO). This tutorial explains: 1. Setting Up the List Assume we already have a reactive list RListReactive<Long> with elements 1–10: 2. Making the List Behave…

  • Working with Reactive Lists in Redisson

    Redisson provides reactive implementations for Redis data structures. Among them, RListReactive allows reactive interaction with Redis lists, enabling asynchronous operations, backpressure handling, and non-blocking I/O. This tutorial focuses on: 1. Setting Up a Reactive List First, you need a reactive Redisson client and a reactive list: Explanation: 2. Adding Elements Reactively Method 1: Using flatMap…

  • Using Redisson Local Cached Maps in Java

    Redisson provides two primary ways to interact with Redis maps: This tutorial focuses on RLocalCachedMap, which is ideal for scenarios with multiple microservices or application instances that need fast local access and eventual consistency. 1. Overview of RLocalCachedMap RLocalCachedMap is a map where: Key Concepts 2. Creating a Local Cached Map Explanation: 3. Sink Strategies…

  • Expiring Individual Fields in Redis Hashes Using Redisson

    Redis allows expiring entire keys, but individual fields in a hash cannot be expired by default. Redisson provides a solution through RMapCache, which supports per-field expiration. This is extremely useful when you want different fields in the same map to have different lifetimes. 1. Introduction to RMapCache RMapCache is an extension of RMap that provides:…