Statistics
58
Views
0
Downloads
0
Donations
Uploader

高宏飞

Shared on 2025-11-25
Support
Share

AuthorSteve Suehring

Curious about Redis? This popular multi-model NoSQL database server enables search, messaging, streaming, graph, and other capabilities—going beyond other NoSQL databases to provide the advanced capabilities modern applications need. Whether you are a developer interested in learning Redis or a manager thinking about implementing Redis in your organization, Redis for Dummies can help.

Tags
No tags
ISBN: 1119824273
Publish Year: 2021
Language: 英文
Pages: 96
File Format: PDF
File Size: 5.9 MB
Support Statistics
¥.00 · 0times
Text Preview (First 20 pages)
Registered users can read the full content for free

Register as a Gaohf Library member to read the complete e-book online for free and enjoy a better reading experience.

(This page has no text content)
These materials are © 2021 John Wiley & Sons, Inc. Any dissemination, distribution, or unauthorized use is strictly prohibited.
These materials are © 2021 John Wiley & Sons, Inc. Any dissemination, distribution, or unauthorized use is strictly prohibited. Redis™ 2nd Limited Edition by Steve Suehring
These materials are © 2021 John Wiley & Sons, Inc. Any dissemination, distribution, or unauthorized use is strictly prohibited. Redis™ For Dummies®, 2nd Limited Edition Published by John Wiley & Sons, Inc. 111 River St. Hoboken, NJ 07030-5774 www.wiley.com Copyright © 2021 by John Wiley & Sons, Inc., Hoboken, New Jersey No part of this publication may be reproduced, stored in a retrieval system or transmitted in any form or by any means, electronic, mechanical, photocopying, recording, scanning or otherwise, except as permitted under Sections 107 or 108 of the 1976 United States Copyright Act, without the prior written permission of the Publisher. Requests to the Publisher for permission should be addressed to the Permissions Department, John Wiley & Sons, Inc., 111 River Street, Hoboken, NJ 07030, (201) 748-6011, fax (201) 748-6008, or online at http://www.wiley.com/go/permissions. Trademarks: Wiley, For Dummies, the Dummies Man logo, The Dummies Way, Dummies.com, Making Everything Easier, and related trade dress are trademarks or registered trademarks of John Wiley & Sons, Inc. and/or its affiliates in the United States and other countries, and may not be used without written permission. All other trademarks are the property of their respective owners. John Wiley & Sons, Inc., is not associated with any product or vendor mentioned in this book. LIMIT OF LIABILITY/DISCLAIMER OF WARRANTY: THE PUBLISHER AND THE AUTHOR MAKE NO REPRESENTATIONS OR WARRANTIES WITH RESPECT TO THE ACCURACY OR COMPLETENESS OF THE CONTENTS OF THIS WORK AND SPECIFICALLY DISCLAIM ALL WARRANTIES, INCLUDING WITHOUT LIMITATION WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE. NO WARRANTY MAY BE CREATED OR EXTENDED BY SALES OR PROMOTIONAL MATERIALS. THE ADVICE AND STRATEGIES CONTAINED HEREIN MAY NOT BE SUITABLE FOR EVERY SITUATION. THIS WORK IS SOLD WITH THE UNDERSTANDING THAT THE PUBLISHER IS NOT ENGAGED IN RENDERING LEGAL, ACCOUNTING, OR OTHER PROFESSIONAL SERVICES. IF PROFESSIONAL ASSISTANCE IS REQUIRED, THE SERVICES OF A COMPETENT PROFESSIONAL PERSON SHOULD BE SOUGHT. NEITHER THE PUBLISHER NOR THE AUTHOR SHALL BE LIABLE FOR DAMAGES ARISING HEREFROM. THE FACT THAT AN ORGANIZATION OR WEBSITE IS REFERRED TO IN THIS WORK AS A CITATION AND/OR A POTENTIAL SOURCE OF FURTHER INFORMATION DOES NOT MEAN THAT THE AUTHOR OR THE PUBLISHER ENDORSES THE INFORMATION THE ORGANIZATION OR WEBSITE MAY PROVIDE OR RECOMMENDATIONS IT MAY MAKE. FURTHER, READERS SHOULD BE AWARE THAT INTERNET WEBSITES LISTED IN THIS WORK MAY HAVE CHANGED OR DISAPPEARED BETWEEN WHEN THIS WORK WAS WRITTEN AND WHEN IT IS READ. For general information on our other products and services, or how to create a custom For Dummies book for your business or organization, please contact our Business Development Department in the U.S. at 877-409-4177, contact info@dummies.biz, or visit www.wiley.com/go/ custompub. For information about licensing the For Dummies brand for products or services, contact BrandedRights&Licenses@Wiley.com. ISBN 978-1-119-82427-5 (pbk); ISBN 978-1-119-82428-2 (ebk) Manufactured in the United States of America 10 9 8 7 6 5 4 3 2 1 Publisher’s Acknowledgments Some of the people who helped bring this book to market include the following: Project Editor: Elizabeth Kuball Acquisitions Editor: Ashley Coffey Editorial Manager: Rev Mengle Business Development Representative: Matt Cox Production Editor: Tamilmani Varadharaj
Table of Contents iii These materials are © 2021 John Wiley & Sons, Inc. Any dissemination, distribution, or unauthorized use is strictly prohibited. Table of Contents INTRODUCTION ............................................................................................... 1 About This Book ................................................................................... 1 Foolish Assumptions ............................................................................ 1 Icons Used in This Book ....................................................................... 2 Where to Go from Here ....................................................................... 2 CHAPTER 1: What Is Redis? ................................................................................ 3 Introducing NoSQL ............................................................................... 3 Defining NoSQL ............................................................................... 3 Identifying types of NoSQL databases ......................................... 4 Knowing when to use NoSQL versus a relational database .......................................................................................... 6 Deciding when to use a NoSQL database .................................... 6 Seeing Where Redis Fits ...................................................................... 7 Data storage .................................................................................... 7 Data structure storage ................................................................... 8 Working with Multi-Model Application Requirements ..................... 9 The single-model problem ............................................................. 9 The modules solution ..................................................................... 9 CHAPTER 2: What Is Redis Used For? ....................................................... 11 Identifying How Redis Can Help You ................................................ 11 Real-time analytics ........................................................................ 11 Fraud detection ............................................................................. 12 Gaming and leaderboards ........................................................... 12 Personalization with session management ............................... 12 Recommendation management ................................................. 13 Social apps ..................................................................................... 13 Search ............................................................................................. 13 Redis in the Real World ...................................................................... 14 Caching ........................................................................................... 14 Large data sets .............................................................................. 14 Full-text fuzzy search .................................................................... 15 Geospatial and time-series data ................................................. 15 Messaging/queuing ...................................................................... 15
iv Redis For Dummies, 2nd Limited Edition These materials are © 2021 John Wiley & Sons, Inc. Any dissemination, distribution, or unauthorized use is strictly prohibited. CHAPTER 3: Getting Started with Redis ................................................. 17 Understanding the Components of Redis ....................................... 17 The server and the command-line interface ............................. 17 The client and drivers ................................................................... 18 Databases, memory, and persistence ........................................ 19 Deploying Redis .................................................................................. 20 Using Redis Enterprise Cloud ...................................................... 20 Compiling Redis from source ...................................................... 21 Using Redis in Docker ................................................................... 24 Homebrewing for macOS ............................................................ 24 Taking the First Steps with Redis ...................................................... 25 Installing the Redis command-line interface ............................. 25 Making your first connection ....................................................... 25 Working with Redis Clients ................................................................ 26 Python ............................................................................................ 27 Java.................................................................................................. 28 Node.js ........................................................................................... 29 Other languages ............................................................................ 29 CHAPTER 4: Using Multi-Model Redis: Data Models, Structures, and Modules ..................................................... 31 Redis Data Models.............................................................................. 32 Strings and bitmaps ...................................................................... 32 Lists ................................................................................................. 34 Sets ................................................................................................. 35 Hashes ............................................................................................ 36 Sorted sets ..................................................................................... 37 HyperLogLog ................................................................................. 38 Patterns and Data Structures ........................................................... 39 Pub/sub .......................................................................................... 39 Geospatial indexes ....................................................................... 40 Redis Streams ................................................................................ 41 Redis Modules .................................................................................... 41 RediSearch ..................................................................................... 41 RedisJSON ...................................................................................... 41 RedisTimeSeries ............................................................................ 42 RedisGraph .................................................................................... 42 RedisBloom .................................................................................... 42 RedisAI ............................................................................................ 43 RedisGears ..................................................................................... 43
Table of Contents v These materials are © 2021 John Wiley & Sons, Inc. Any dissemination, distribution, or unauthorized use is strictly prohibited. CHAPTER 5: Redis Architecture and Topology ................................. 45 Understanding Clustering and High Availability ............................. 45 Redis Enterprise cluster architecture ......................................... 46 High availability ............................................................................. 46 Running Redis at scale ................................................................. 47 Redis on Flash ............................................................................... 48 Examining Transactions and Durability ........................................... 48 ACID ................................................................................................ 48 Durability........................................................................................ 50 CHAPTER 6: Using Redis Enterprise Software and Redis Enterprise Cloud ......................................................................... 51 Understanding Redis Enterprise Software and Redis Enterprise Cloud ...................................................................... 51 Getting Started with Redis Enterprise Software and RedisInsight ................................................................................. 53 Meeting the prerequisites............................................................ 53 Installing Redis Enterprise in a Docker container ..................... 54 Understanding concepts and architecture ................................ 58 Connecting with RedisInsight ...................................................... 59 CHAPTER 7: A Simple Redis Application ................................................ 63 Getting Started ................................................................................... 63 Prerequisites.................................................................................. 63 Front-end application code.......................................................... 64 Creating a CRUD App ......................................................................... 64 Cars (sets) ....................................................................................... 65 Features (lists) ............................................................................... 66 Car descriptions (hashes) ............................................................. 67 CHAPTER 8: Building an Application with RediSearch ............... 69 Using RediSearch for Movie Data ..................................................... 69 Installing RediSearch .................................................................... 69 Inserting data ................................................................................ 71 Working with Data and Indexes ....................................................... 72 Querying data ................................................................................ 72 Adding and viewing indexes ........................................................ 73 Searching data ............................................................................... 74
vi Redis For Dummies, 2nd Limited Edition These materials are © 2021 John Wiley & Sons, Inc. Any dissemination, distribution, or unauthorized use is strictly prohibited. CHAPTER 9: Developing an Active-Active/Conflict-Free Replicated Data Type Application ................................ 77 Getting Acquainted with Conflict-Free Replicated Data Types ..... 77 Defining conflict-free replicated data types .............................. 78 Looking at how they’re different ................................................. 78 Understanding why and where you need them ....................... 78 Working with Conflict-Free Replicated Data Types ........................ 79 Getting an overview of the application ...................................... 79 Considering the prerequisites ..................................................... 80 Starting the containers ................................................................. 80 Testing the conflict-free replicated data type ............................ 82 Watching Conflict-Free Replicated Data Types at Work ................ 83 Setting up the example code environment ............................... 83 Viewing the example with a healthy network ........................... 84 Breaking the network connection between clusters ................ 86 Viewing the example in a split network ..................................... 86 Rejoining the network .................................................................. 87 Looking at the example in a rejoined network ......................... 87 CHAPTER 10: Ten Things You Can Do with Redis .............................. 89
Introduction 1 These materials are © 2021 John Wiley & Sons, Inc. Any dissemination, distribution, or unauthorized use is strictly prohibited. Introduction NoSQL is a modern data persistence storage paradigm that provides data persistence for environments where high performance is a primary requirement. Within NoSQL, data is stored in such a way as to make both writing and reading quite fast, even under heavy load. Redis and Redis Enterprise are market-leading, multi-model NoSQL databases that bring NoSQL to organizations both big and small. Redis is open source, and Redis Enterprise software adds several enhancements that are important to the enterprise cus- tomer. Redis Enterprise Cloud enables Redis Enterprise deploy- ments on popular cloud providers like Amazon Web Services (AWS), Google Cloud, and Microsoft Azure. About This Book This book provides a starting point for those new to NoSQL and those who have heard about NoSQL but would like to see how it might be used in their organization. The book serves multiple audiences, with chapters geared towards managers and chapters specifically for developers. You don’t need to read this book from front to back, but you certainly can! Foolish Assumptions In writing this book, I assumed that you’re familiar with data- bases, at least at a basic level. If you’re a developer, you should have an environment available on which you can install things. I show examples in later chapters using Redis that also utilize Docker and GitHub, so having a development environment avail- able will be helpful, but it isn’t required — you can follow along even if you don’t run the examples yourself.
2 Redis For Dummies, 2nd Limited Edition These materials are © 2021 John Wiley & Sons, Inc. Any dissemination, distribution, or unauthorized use is strictly prohibited. Icons Used in This Book Throughout this book, I occasionally use special icons to call attention to important information. Here’s what to expect: The Remember icon points out information you should commit to your nonvolatile memory, your gray matter, or your noggin — along with anniversaries and birthdays! You won’t find a map of the human genome here, but if you seek to attain the seventh level of NERD-vana, perk up! The Technical Stuff icon explains the jargon beneath the jargon! Tips are appreciated, never expected, and I sure hope you’ll appreciate the nuggets of information marked by the Tip icon. The Warning icon points out the stuff your mother warned you about. Well, probably not, but these paragraphs do offer practical advice to help you avoid potentially costly or frustrating mistakes. Where to Go from Here There’s a lot more to Redis than is covered in this book. To con- tinue exploring all the capabilities that Redis offers, visit https:// redislabs.com.
CHAPTER 1 What Is Redis? 3 These materials are © 2021 John Wiley & Sons, Inc. Any dissemination, distribution, or unauthorized use is strictly prohibited. Chapter 1 IN THIS CHAPTER » Getting acquainted with NoSQL » Understanding what Redis brings to the table » Creating a multi-model database with Redis What Is Redis? In this chapter, I offer an overview of NoSQL, including the types of NoSQL databases (such as key/value, document, column, and graph). I also compare NoSQL to methods for traditional data persistence. Finally, I introduce Redis, a popular multi-model database server. Redis goes beyond a NoSQL database to provide several advanced capabilities needed by modern applications. Introducing NoSQL The term NoSQL is used to describe a set of technologies for data storage. In this section, I explain what NoSQL is, outline the major types of NoSQL databases, and compare NoSQL to relational databases. Defining NoSQL NoSQL describes technologies for data storage, but what exactly does that mean? Is NoSQL an abbreviation for something? I answer these and other pressing questions in this section. Depending on whom you ask, NoSQL may stand for “not only SQL” or it may not stand for anything at all. Regardless of any disagreement over what NoSQL stands for, everyone agrees that NoSQL is a robust set of technologies that enable data persistence
4 Redis For Dummies, 2nd Limited Edition These materials are © 2021 John Wiley & Sons, Inc. Any dissemination, distribution, or unauthorized use is strictly prohibited. with the high performance necessary for today’s Internet-scale applications. SQL is an abbreviation for Standard Query Language, a standard language for manipulating data within a relational database. Identifying types of NoSQL databases There are four major types of NoSQL databases — key/value, col- umn, document, and graph — and each has a particular use case for which it’s most suited. The following sections go into greater detail on the four types of NoSQL. Key/value With a key/value storage format, data uses keys (identifiers that are similar to a primary key in a relational database). The data element itself is then the value that corresponds to the key. Figure 1-1 illustrates the concept of key/value pairs using a phone directory. In this example, a person’s name provides the key and the value is then the corresponding phone number. Column With a column-oriented data store, data is arranged by column rather than by row. The effect of this architectural design is that it makes aggregate queries over large amounts of data much faster to process. Document Document data storage in NoSQL uses a key as the basis for item retrieval. The key then corresponds to a more complex data struc- ture, called a document, which contains the data elements for a given collection of data. FIGURE 1-1: A phone directory is an example of a key/value pair data store.
CHAPTER 1 What Is Redis? 5 These materials are © 2021 John Wiley & Sons, Inc. Any dissemination, distribution, or unauthorized use is strictly prohibited. Figure 1-2 shows an example of a document database in JavaScript Object Notation (JSON) format. The example shows information about a book, such as its unique identifier, title, author, and year. Each of these items could then be parsed using a JSON parser into key/value, as shown in the figure. Graph Graph databases use graph theory to store data relations in a series of vertices with edges, making queries that work with data in such a manner much faster. Figure  1-3 depicts relationships between three different entities, each containing labels that help to describe the entity. FIGURE 1-2: A document database example containing information about a book. FIGURE 1-3: A graph database depicting relationships between data elements.
6 Redis For Dummies, 2nd Limited Edition These materials are © 2021 John Wiley & Sons, Inc. Any dissemination, distribution, or unauthorized use is strictly prohibited. Knowing when to use NoSQL versus a relational database Regardless of the type of NoSQL database, the patterns and tools that you use to work with data are different from the patterns and tools that you typically find with a relational database. The para- digm for storage and the arrangement of the data typically require a rethink of how applications are created. Relational databases connect data elements through relations between tables. These relations become quite complex for many applications, and the resulting queries against the data become equally complex. The inherent complexity leads to performance issues for queries. Many traditional databases include query tools and software to directly manipulate data. With NoSQL, most access will be pro- grammatic only, through applications that you write using the tools and application programming interfaces (APIs) for the NoSQL database. A relational database has somewhat less flexibility than soft- ware such as Redis that implements NoSQL. Whereas a relational database thrives when data is consistent and well structured, Redis and NoSQL thrive on the unstructured data that is found in today’s modern applications, while also providing the flexibility to structure data as needed. Redis can implement multiple rep- resentations of a data model. You can find more information on Redis as a multi-model database later in this chapter. Deciding when to use a NoSQL database Comparing a NoSQL database to a relational database may have you thinking about the specific uses for NoSQL.  NoSQL excels when fast access to large amounts of data is needed. NoSQL is also excellent at enabling developers to work with a flexible data model, as is frequently the case with modern applications. In these scenarios, the data model may not be immediately or fully known. However, developers need to get started programming the application itself and can use NoSQL for flexible data models that support both semi-structured and unstructured data.
CHAPTER 1 What Is Redis? 7 These materials are © 2021 John Wiley & Sons, Inc. Any dissemination, distribution, or unauthorized use is strictly prohibited. When it comes time to move to production, a NoSQL database offers highly available replicated data. Unlike a traditional rela- tional database, NoSQL data is replicated without need for pri- mary read/write and secondary read-only nodes. Replicated data is kept consistent by design, and NoSQL databases utilize a shared-nothing approach to ensure high availability. Both tra- ditional and NoSQL databases handle scaling through sharding but the consistency model required for horizontal scaling requires significant forethought and effort with a relational database. Sharding is a means to partition or split data into smaller pieces that are distributed to different computing resources. For instance, data may be sharded according to the geographic location where it is most frequently used and then stored in a data center close to the users in order to decrease latency. Read/write speed is typically much higher with NoSQL when compared with a traditional relational database system. NoSQL also thrives with unstructured data, whereas a relational database needs to have a schema declared prior to any data being entered into the system. Schema changes due to new requirements can require significant rework with a traditional database. Queries with a normalized relational data model can be quite time- and resource-intensive, which is not usually acceptable for real-time application needs. These complex queries don’t scale well either. NoSQL thrives in the modern application development life cycle and operates at Internet scale with ease. Look first to NoSQL data- bases when you’re working with unstructured data that changes frequently or needs to scale up and out, or when large volumes of data are involved. Seeing Where Redis Fits Redis is a NoSQL database, but it’s also much more. Redis is a multi-model database enabling search, messaging, streaming, graph, and other capabilities beyond that of a simple data store. Data storage Redis keeps data in memory for fast access and persists data to storage, in addition to replicating in-memory contents for high- availability production scenarios.
8 Redis For Dummies, 2nd Limited Edition These materials are © 2021 John Wiley & Sons, Inc. Any dissemination, distribution, or unauthorized use is strictly prohibited. When discussing data storage, the concept of durability becomes important. Durability is the ability to ensure that data is available in the event of a failure of a database component. Redis supports multiple modes for ensuring durability, accommodating most data structures and environment-specific requirements. Data structure storage Redis supports several data structures. In fact, it may be helpful to think of Redis as a data structures store rather than a simple key/ value NoSQL store. Supported data structures include » Strings » Lists » Sets » Sorted Sets » Hashes » Bit Arrays » HyperLogLogs » Streams » Geospatial Indexes Each data structure has a different use case or scenario for which it is best suited. Beyond these data structures, Redis also supports the Publish/ Subscribe (Pub/Sub) pattern and additional patterns that make Redis suitable for modern data-intensive applications. Geo data structures include commands that analyze geospatial data in order to calculate distances, find members within a particular distance from each other, and other analysis pertinent to geographically-relevant data. This design enables reduced code complexity, reduced network consumption, and overall faster execution.
CHAPTER 1 What Is Redis? 9 These materials are © 2021 John Wiley & Sons, Inc. Any dissemination, distribution, or unauthorized use is strictly prohibited. Working with Multi-Model Application Requirements Multi-model databases support multiple data models with a sin- gle, integrated back-end server application. Redis provides full multi-model functionality through Redis Modules. Redis Modules are customized, prebuilt functionality that enable the addition of data structures in a modular fashion. As such, Redis Modules open the door to adding other data models, such as graph and full- text search. Redis Modules also lead to other capabilities such as improved JSON support, secondary indexes, linear algebra, SQL support, and image processing. The use of Redis as a multi-model database enables greater flexibility for application developers within an organization. The single-model problem A single data model, a choice typically made at the beginning of a project, can prove to be a development and performance bottle- neck as the project and application evolve. At the very least, deci- sions made about how to represent and interact with data can incur technical debt that is difficult to pay back. One approach to solve the technical debt issue is with a multi- model database. However, multi-model databases frequently only gloss over the issue by adding application-level or integration- layer code to present the data using a different model. Redis takes a different approach. The modules solution Redis modules make it possible to extend Redis functionality using external modules, rapidly implementing new Redis com- mands with features similar to what can be done inside the core itself. Redis Modules is designed to plug into the open-source Redis database, taking advantage of functionality such as in- memory processing, scalability, and high availability. Through its modularity of design, Redis provides capabilities necessary for many different types of applications.
CHAPTER 2 What Is Redis Used For? 11 These materials are © 2021 John Wiley & Sons, Inc. Any dissemination, distribution, or unauthorized use is strictly prohibited. Chapter 2 IN THIS CHAPTER » Seeing how Redis can help you » Looking at a real-world example What Is Redis Used For? In this chapter, I give you an overview of some of the specific ways that Redis can help. Chapter  1 shares a bit more about specific components of Redis, including Redis Modules. This chapter concludes with an example of how Redis is used for real- time practical applications. Identifying How Redis Can Help You This section examines several popular use cases for Redis. Redis has the necessary capabilities to meet user expectations for per- formance and features. For example, benchmarks show that Redis Enterprise in an ACID configuration is able to perform more than 500,000 operations per second with sub-millisecond latency and can also achieve 50 million operations per second with the same performance on only 26 compute nodes. The performance of Redis — coupled with search features like autocomplete and result highlighting — improves the entire user experience. Real-time analytics Redis is exceptionally good for real-time analytic calculations like top scores, top-ranked contributors, top posts, and more. Fast-paced calculations of the type needed for instant scoring in a game or last-minute bidding in an auction can use Redis Sorted
12 Redis For Dummies, 2nd Limited Edition These materials are © 2021 John Wiley & Sons, Inc. Any dissemination, distribution, or unauthorized use is strictly prohibited. Sets. Sorted Sets keep track of ordering automatically, enabling you to obtain top scores or the high bidder with native commands like ZRANGE and ZREVRANGE. Because Sorted Sets do the work behind the scenes when ZADD is used to add values, you no longer need to expend resources sorting the result set. Fraud detection Detecting fraud in transactions is always important. As attacks become more sophisticated, the need for specialized and instant fraud detection becomes increasingly vital. As a customer nav- igates through a shopping or financial transaction, a record of that transaction can be captured in Redis Streams, fed into Redis Bloom for fraud probability scoring, and coupled with RedisAI to provide full analysis of the transaction. As transactions move through the system, technologies such as Redis TimeSeries can help spot trends that may indicate fraud. Gaming and leaderboards Although real-time analytics alluded to this use case, the high- light around gaming and leaderboard tracking with Redis is the ability to run at scale and increase data-set size without affect- ing performance or needing to re-architect the application code. Additionally, Internet-based gaming naturally enables players from around the world who expect instant feedback. The high- availability nature of Redis enables data to be geographically dis- tributed to shorten the distance and, thus, the latency between the player and their scoring status. Sorted Sets are used for gaming and leaderboards. Commands such as HSET help to store values in a structured manner for easier retrieval. The resulting hash can then be associated with a Sorted Set to take full advantage of the native capabilities for sorting data automatically. Personalization with session management A session is loaded when a user logs in or when they’re using the application in order to track their activity. By nature, session- related data needs to be readily available, with low latency to meet performance requirements that users expect.
CHAPTER 2 What Is Redis Used For? 13 These materials are © 2021 John Wiley & Sons, Inc. Any dissemination, distribution, or unauthorized use is strictly prohibited. Redis is a great fit for such applications because data is available in-memory and Hash data structure enables data to be stored in multiple fields while facilitating the flexibility to use other data structures. In the event of an outage, immediate failover is still available even though the data is maintained within the low- latency in-memory storage. Recommendation management Redis Sets enable easy tracking of items by simple tagging, which facilitates a recommendation engine for products. For example, data from users with similar purchases that is stored as a Redis Set can be analyzed for common items by using the SINTER com- mand to look for the intersection of products. The SADD com- mand is used to tag each product with keywords to help with this use case. Social apps End users expect real-time or near-real-time performance from social apps. From chat to follows to comments to games, social apps present a challenge for disk-based data stores. An in- memory data store provides the performance necessary for these applications. Several features of Redis make implementation of social app fea- tures possible: » Intelligent caching » Publish/subscribe (pub/sub) pattern for incoming data » Job and queue management » Built-in analytics » Native JSON-handling JavaScript Object Notation (JSON) is a structured data format. Because it’s native JavaScript, JSON-formatted data can be used directly in an app without needing to be transformed into another format. Search RediSearch is a powerful indexing, querying, and full-text search engine for Redis. Allowing users to search data is difficult.
The above is a preview of the first 20 pages. Register to read the complete e-book.