Redis Stack for Application Modernization

Book description

Discover the multi-model capabilities of Redis Stack as a document store and vector database, with support for time series, stream processing, probabilistic data structures, and more

Key Features

  • Model, index, and search data using JSON and vector data types
  • Modernize your applications with vector similarity search, documents hybrid search, and more
  • Configure a scalable, highly available, and secure server using RedisInsight
  • Purchase of the print or Kindle book includes a free PDF eBook

Book Description

In modern applications, efficiency in both operational and analytical aspects is paramount, demanding predictable performance across varied workloads. This book introduces you to Redis Stack, an extension of Redis and guides you through its broad data modeling capabilities. With practical examples of real-time queries and searches, you’ll explore Redis Stack’s new approach to providing a rich data modeling experience all within the same database server.

You’ll learn how to model and search your data in the JSON and hash data types and work with features such as vector similarity search, which adds semantic search capabilities to your applications to search for similar texts, images, or audio files. The book also shows you how to use the probabilistic Bloom filters to efficiently resolve recurrent big data problems. As you uncover the strengths of Redis Stack as a data platform, you’ll explore use cases for managing database events and leveraging introduce stream processing features. Finally, you’ll see how Redis Stack seamlessly integrates into microservices architectures, completing the picture.

By the end of this book, you’ll be equipped with best practices for administering and managing the server, ensuring scalability, high availability, data integrity, stored functions, and more.

What you will learn

  • Get started with data modeling using JSON and hash documents, vectors, and time series
  • Implement microservices patterns and resolve typical use cases
  • Use probabilistic data structures to analyze datasets and streams
  • Integrate Redis Stack into your Java, Python, C#, Golang, and Node.js projects
  • Develop powerful data flows using triggers and stream processing features
  • Manage your database server for scalability, high availability, and security
  • Visualize and manage your data with RedisInsight

Who this book is for

This book is for database administrators, database developers, software developers, and software architects who want to discover the powerful real-time, multi-model capabilities of the Redis Stack database. A basic understanding of Redis and databases in general, coupled with software development skills in at least one of Java, Python, C#, Golang, or JavaScript languages will help you understand the concepts covered in this book.

Table of contents

  1. Redis Stack for Application Modernization
  2. Contributors
  3. About the authors
  4. About the reviewer
  5. Preface
    1. Who this book is for
    2. What this book covers
    3. To get the most out of this book
    4. Download the example code files
    5. Conventions used
    6. Get in touch
    7. Share Your Thoughts
    8. Download a free PDF copy of this book
  6. Part 1: Introduction to Redis Stack
  7. Chapter 1: Introducing Redis Stack
    1. Technical requirements
    2. Exploring the history of Redis
    3. The open source project
    4. From key-value to multi-model real-time databases
      1. Primary key lookup
      2. Secondary key lookup
      3. Pipelining
      4. Using functions
      5. Using indexes
      6. Redis Stack capabilities
      7. So, what is Redis Stack?
    5. Redis Stack deployment types
    6. Summary
  8. Chapter 2: Developing Modern Use Cases with Redis Stack
    1. Technical requirements
    2. Caching, rate-limiting, geo-positioning, and other Redis traditional use cases
      1. Caching
      2. Session store
      3. Rate limiter
      4. Leaderboards
      5. Data deduplication
      6. Geo-positioning
      7. Message processing and delivery
    3. Going beyond the real-time cache with Redis Stack
      1. Querying, indexing, and search
      2. Monitoring and analysis
      3. Fraud detection
      4. Feature store for machine learning
    4. Designing microservice architectures with Redis Stack
      1. API gateway
    5. Summary
  9. Chapter 3: Getting Started with Redis Stack
    1. Installing Redis Stack using binary packages
    2. Installing Redis Stack using native packages
      1. macOS-native package
      2. Linux-native package
      3. Running Redis Stack using Docker
    3. Using Redis Cloud
    4. Installing RedisInsight
    5. Installing the Redis Stack client libraries
      1. Java client library
      2. JavaScript client library
      3. Python client library
      4. Golang client library
      5. C#/.NET client library
    6. Running health checks
    7. Summary
  10. Chapter 4: Setting Up Client Libraries
    1. Technical requirements
    2. Redis Stack client libraries
    3. Programming in Python using redis-py
      1. Storing information in Redis Stack using Python
      2. Redis OM for Python
    4. Programming in Java using Jedis
      1. Storing information in Redis Stack using Java
      2. Redis OM for Java
    5. Programming in JavaScript using node-redis
      1. Redis OM for JavaScript
    6. Programming in Go using go-redis
      1. Storing information in Redis Stack using Go
    7. Programming in C#/.NET using NRedisStack
      1. Storing information in Redis Stack using C#/.NET
      2. Redis OM for C#/.NET
    8. Summary
  11. Part 2: Data Modeling
  12. Chapter 5: Redis Stack as a Document Store
    1. Technical requirements
    2. Storing and querying documents in Redis Stack
      1. The dialect and other configuration parameters
      2. The query language
      3. Simple terms
      4. Using field modifiers
      5. Intersection of results (AND)
      6. Union of results (OR)
      7. Exact query matches
      8. Stop words
      9. Negation and purely negative queries
      10. Prefix, infix, and suffix queries
      11. Wildcard matching
      12. Fuzzy matching
      13. Numeric filters
      14. Tag filters
      15. Geospatial filters
      16. Aggregation and transformation
      17. Cursor-based requests
      18. Faceted search using aggregations
      19. Updating an index in production
      20. Temporary indexes
      21. Additional commands
    3. Working with Hashes
      1. Highlighting and summarizing
      2. Synonyms support
      3. Spellchecking
      4. Auto-completion
      5. Phonetic matching
    4. Working with JSON
      1. The JSONPath syntax
      2. Indexing a JSON document
      3. Indexing arrays and objects
      4. Multi-value indexing
      5. Extracting partial data from JSON documents
    5. Redis Stack as a recommendation engine
      1. Recommendation using scores
    6. Redis Stack as a session store
      1. Redis data structures for session data
      2. Additional Redis data structures
      3. Modeling key-value pairs
      4. Modeling objects
      5. Modeling collections
      6. Session management for real-time applications
    7. Summary
  13. Chapter 6: Redis Stack as a Vector Database
    1. Technical requirements
    2. Vector embeddings for unstructured data modeling
    3. Storing the embeddings
      1. Hashes
      2. JSON
    4. Indexing the embeddings
      1. The algorithms – FLAT and HNSW
      2. Type
      3. Index dimension
      4. Distance metrics
    5. Performing similarity search
    6. Performing hybrid queries
    7. Performing VSS range queries
    8. Recommendations based on visual search
    9. Integrating Redis with generative AI
    10. Summary
  14. Chapter 7: Redis Stack as a Time Series Database
    1. Technical requirements
    2. Why Redis Stack for Time Series?
    3. Working with time series
    4. Adding labels to data points
    5. Aggregation framework
    6. Compaction rules for Time Series
    7. Summary
  15. Chapter 8: Understanding Probabilistic Data Structures
    1. Technical requirements
    2. HyperLogLog
    3. Bloom filter
    4. Cuckoo filters
    5. Count-Min sketch
    6. Top-K
    7. t-digest
    8. Summary
  16. Part 3: From Development to Production
  17. Chapter 9: The Programmability of Redis Stack
    1. Technical requirements
    2. The single-threaded architecture
    3. Programming complex business logic with Redis Stack
    4. Lua scripting
    5. Redis functions
    6. Triggers and functions
      1. Anatomy of a function
      2. Working with data
      3. Batch processing
      4. Asynchronous functions
      5. Cluster awareness
      6. Keyspace triggers
      7. Stream triggers
      8. Comparing Lua scripts, Lua functions, and JavaScript functions
    7. Summary
  18. Chapter 10: RedisInsight – the Data Management GUI
    1. Technical requirements
    2. Connecting to the Redis Stack database
      1. Browsing keys
    3. Interacting with data
    4. Analyzing data
      1. Troubleshooting PubSub channels
    5. Summary
  19. Chapter 11: Using Redis Stack as a Primary Database
    1. Technical requirements
    2. What is a primary database?
    3. Redis as a primary database
    4. The BASE and ACID properties
      1. The BASE properties
      2. The ACID properties
    5. Configuring Redis for durability, consistency, and availability
      1. Configuring snapshots
      2. Configuring AOF
      3. Configuring high availability
      4. Configuring consistency
    6. Summary
  20. Chapter 12: Managing Development and Production Environments
    1. Technical requirements
    2. Redis Stack as a development environment
      1. HA
      2. Scalability
      3. Security
      4. Limitations
    3. Preparing for production with Redis Enterprise
      1. Redis Enterprise architecture
      2. A multi-tenancy architecture
      3. HA
      4. Horizontal and vertical scalability and dynamic auto-tiering
      5. Security hardening
      6. Observability and monitoring
    4. Redis Cloud – an enterprise-ready Redis DBaaS
    5. Summary
  21. Index
    1. Why subscribe?
  22. Other Books You May Enjoy
    1. Packt is searching for authors like you
    2. Share Your Thoughts
    3. Download a free PDF copy of this book

Product information

  • Title: Redis Stack for Application Modernization
  • Author(s): Luigi Fugaro, Mirko Ortensi
  • Release date: December 2023
  • Publisher(s): Packt Publishing
  • ISBN: 9781837638185