Book Image

Redis 4.x Cookbook

Book Image

Redis 4.x Cookbook

Overview of this book

Redis is considered the world's most popular key-value store database. Its versatility and the wide variety of use cases it enables have made it a popular choice of database for many enterprises. Based on the latest version of Redis, this book provides both step-by-step recipes and relevant the background information required to utilize its features to the fullest. It covers everything from a basic understanding of Redis data types to advanced aspects of Redis high availability, clustering, administration, and troubleshooting. This book will be your great companion to master all aspects of Redis. The book starts off by installing and configuring Redis for you to get started with ease. Moving on, all the data types and features of Redis are introduced in detail. Next, you will learn how to develop applications with Redis in Java, Python, and the Spring Boot web framework. You will also learn replication tasks, which will help you to troubleshoot replication issues. Furthermore, you will learn the steps that need to be undertaken to ensure high availability on your cluster and during production deployment. Toward the end of the book, you will learn the topmost tasks that will help you to troubleshoot your ecosystem efficiently, along with extending Redis by using different modules.
Table of Contents (21 chapters)
Title Page
Packt Upsell
Windows Environment Setup


I still remember how surprised I was when for the first time I heard about Redis. It's so elegant and powerful, like a Swiss Army knife for your backend applications, and of course, it’s blazing fast. In modern data centers, the unit cost of RAM is getting lower and lower; it's no surprise that Redis is playing an important role in storage stacks of modern applications. Frankly speaking, Redis is way beyond an in-memory cache.

I’m a database engineer. Codis, a distributed Redis middleware, is my first open source project, which is widely used in the community. I’m quite proud of it. Codis provides a proxy-based solution to tackle the scalability problem of Redis and it’s an alternative to Redis Cluster. As one of the earliest adopters and developers of Redis in China, I witnessed the increasing popularity of Redis. Still more thanks to Redis that I met my dear friend, Redis expert, and contributor, Pengcheng Huang. When he told me he wanted to write a book about Redis, I told him I would definitely buy one. Finally, he made it, and it’s my honor and pleasure to review the early version and write a foreword in this book.

You won’t regret choosing this book. Many significant changes and features were introduced after Redis 4.0 was released. Whether you are new to Redis or an experienced Redis developer like me, you’ll learn new tricks from this book.


Dongxu Huang   

PingCap CTO and Codislabs cofounder




As a contributor and member of the Redisson project as well as a long-time Redis advocate, I have witnessed Redis steadily taking over the world over the years as it evolved from one version to another. After having several conversations with many members of both Redis and Redisson communities, I couldn’t help but wonder: wouldn’t it be great if there were a canonical book with the most up-to-date information on Redis so that Redis users don’t have to trawl through tons of Stack Overflow questions to get the answers they were looking for?

Quite obviously, Pengcheng and Zuofei shared the same vision.

I have known Pengcheng for quite some time. He is a well-known Redis enthusiast in the Redis Chinese community, managing a very active user group full of members ranging from Redis core contributors and tools/library authors, to Redis advocates and everyday users. This book is about what Pengcheng knows best: Redis, or Redis version 4 to be more precise. As one might imagine, he doesn’t manage a user group for a living. He serves as a team lead of big data infrastructure and the technical director of Redis in China Minsheng Bank. His responsibility is to ensure that Redis, as one of the most important parts of the bank’s infrastructure, is being implemented and managed correctly throughout. It is his work at the bank that had helped plant the seeds that would eventually grow into this book.

As a result, the book covers a wide range of topics and is organized in a logical order, primarily catering to beginners and intermediate users. Beginners, you can find plenty of useful examples, diagrams, and how-to guides to help you read through the entire book. Intermediary readers, you will be very pleased to see that the authors were not shy when diving into the depths of how everything in Redis works, along with recommendations for further reading on each topic.

Personally, I quite like the detailed explanations of each Redis configuration option. I think this book will serve me well as a useful handbook, to be kept at the side of my table for quick reference. I hope you will find this book as enjoyable to read as I have, and that it will prove useful as you explore the many wonderful features of Redis 4.


Rui Gu

Long-time Redis advocate, contributor and core developer, Redisson Team