Practical Redis: Session Management, Caching, Flash Sales, and Advanced Data Structures

Stateless Authentication with RedisIn a distributed architecture, relying on Tomcat's local sessions for user state leads to inconsistencies across instances. Redis serves as a centralized session store to solve this. When a user logs in via SMS, a unique token is generated and stored in Redis as the key, with the serialized user DTO as the val ...

Posted on Thu, 21 May 2026 18:30:50 +0000 by JohnN4

MyBatis Caching: First-Level, Second-Level, and EHCache Integration

Understanding MyBatis Caching Mechanisms MyBatis incorporates an internal caching system designed to enhance application performance by minimizing redundant database interactions. This caching operates at two distinct levels: a local, session-scoped cache and a global, application-scoped cache. First-Level Cache: SqlSession Scope The first-leve ...

Posted on Wed, 20 May 2026 16:32:32 +0000 by Jackount

Using Redis Caching in MyBatis Operations with Spring Boot

In the previous article, we explored Spring Boot integration with Redis. This article focuses on implementing Redis caching in MyBatis operations. We'll examine four key annotations: @CachePut, @Cacheable, @CacheEvict, and @CacheConfig. Fundamentals @Cacheable The @Cacheable annotation configures method-level caching, storing results based on m ...

Posted on Wed, 20 May 2026 07:19:39 +0000 by santhosh_89

LFU Cache Algorithm Implementation Analysis

Introduction to LFU Caching LFU (Least Frequently Used) is a caching algorithm that removes the least frequently accessed items when the cache reaches its capacity. Unlike LRU (Least Recently Used), which considers only recency, LFU prioritizes access frequency. Comparison of LFU and LRU Consider a cache with capacity 3 and the following access ...

Posted on Tue, 19 May 2026 20:46:03 +0000 by stylefrog

Understanding and Mitigating Common Cache Issues: Penetration, Breakdown, and Avalanche

Cache Penetration Cache penetration occurs when a large number of requests target data that exists neither in the cache nor in the database. For example, if users repeatedly request non-existent order numbers like -1, these requests bypass the cache entirely and hit the database directly. This scenario can be exploited maliciously to overwhelm ...

Posted on Mon, 18 May 2026 23:33:18 +0000 by yes3no2

Ensuring Redis Cache and Database Consistency with Delayed Double Deletion

Redis Cache and Database Consistency Caching improves performance and reduces database load, but introduces potential inconsistencies between cached data and the database. Inconsistent data leads to stale reads from the cache. Non-Concurrency Scenarios Update Cache First, Then Database If cache udpate succeeds but database update fails, the cac ...

Posted on Mon, 18 May 2026 21:24:00 +0000 by DwarV

Using ReentrantReadWriteLock in JUC and Simple Applications

ReentrantReadWriteLock Introduction and Usage Overview ReentrantReadWriteLock is ideal for scenarios with far more read operations than write operations. It allows concurrent read access while ensuring mutual exclusion between reads and writes, or between writes and writes—similar to database shared locks (select ... from ... lock in share mode ...

Posted on Sun, 17 May 2026 07:45:46 +0000 by !jazz

Redis Core Knowledge for Java Backend Interviews

What is Redis Redis is a high‑performance, in‑memory key‑value database that also supports optional data persistence. It is open‑source and written in C, widely used both as a cache and as a primary datastore for specialised scenarios. Why Redis Is So Fast In‑memory storage – data is served directly from RAM, avoiding disk I/O for most operati ...

Posted on Sat, 16 May 2026 00:09:43 +0000 by dave420

Addressing Cache Anomalies and Advanced Redis Mechanisms

Cache Anomalies Cache Penetration: Requested data does not exist in the system. Use a Bloom filter. Cache Breakdown: A hot key expires. Implement mutual exclusion locks. Apply logical expiration (no actual TTL set). Cache Avalanche: Numerous keys expire simultaneously. Assign random expiration times. Deploy a Redis cluster. Cache Pen ...

Posted on Fri, 15 May 2026 18:47:14 +0000 by tekkenlord

Deploying and Configuring Varnish for Static-Dynamic Content Routing on CentOS

Building Varnish from Source Begin by preparing the required system libraries. Compile and install PCRE2 from source: tar -xzf pcre2-10.23.tar.gz cd pcre2-10.23 ./configure --prefix=/opt/pcre2 make && make install Update the package configuration environment variable and install remaining dependencies via YUM: export PKG_CONFIG_PATH=/o ...

Posted on Thu, 14 May 2026 23:38:54 +0000 by nscipione