You are previewing Mastering Redis.
O'Reilly logo
Mastering Redis

Book Description

Take your knowledge of Redis to the next level to build enthralling applications with ease

About This Book

  • Detailed explanation on Data structure server with powerful strings, lists, sets, sorted-sets, and hashes

  • Learn to Scale your data with Redis Cluster’s distributed setup

  • This is a fast paced practical guide full of screenshots and real work examples to help you get to grips with Redis in no time.

  • Who This Book Is For

    If you are a software developer with some experience with Redis and would now like to elevate your Redis knowledge and skills even further, then this book is for you.

    What You Will Learn

  • Choose the right Redis data structure for your problem

  • Understand Redis event-loop and implement your own custom C commands

  • Solve complex workflows with Redis server-side scripting with Lua

  • Configure your Redis instance for optimal memory management

  • Scale your data in a distributed manner with Redis Cluster

  • Improve the stability of your Redis solution using Redis Sentinel

  • Complement your existing database and NoSQL environment with Redis

  • Exploit a wide range of features provided by Redis to become a DevOps expert.

  • In Detail

    Redis is the most popular, open-source, key value data structure server that provides a wide range of capabilities on which multiple platforms can be be built. Its fast and flexible data structures give your existing applications an edge in the development environment.

    This book is a practical guide which aims to help you deep dive into the world of Redis data structure to exploit its excellent features. We start our journey by understanding the need of Redis in brief, followed by an explanation of Advanced key management. Next, you will learn about design patterns, best practices for using Redis in DevOps environment and Docker containerization paradigm in detail. After this, you will understand the concept of scaling with Redis cluster and Redis Sentinel , followed by a through explanation of incorporating Redis with NoSQL technologies such as Elasticsearch and MongoDB. At the end of this section, you will be able to develop competent applications using these technologies. You will then explore the message queuing and task management features of Redis and will be able to implement them in your applications. Finally, you will learn how Redis can be used to build real-time data analytic dashboards, for different disparate data streams.

    Style and approach

    This is a hands on guide full of easy-to-follow examples, that illustrate important concepts and techniques to solve complex problems with Redis.

    Downloading the example code for this book. You can download the example code files for all Packt books you have purchased from your account at http://www.PacktPub.com. If you purchased this book elsewhere, you can visit http://www.PacktPub.com/support and register to have the code file.

    Table of Contents

    1. Mastering Redis
      1. Table of Contents
      2. Mastering Redis
      3. Credits
      4. About the Author
      5. About the Reviewers
      6. www.PacktPub.com
        1. eBooks, discount offers, and more
          1. Why subscribe?
      7. Preface
        1. The philosophy behind Redis
        2. What this book covers
        3. Earn your Mastering Redis Open Badge
        4. What you need for this book
        5. Who this book is for
        6. Conventions
        7. Reader feedback
        8. Customer support
          1. Downloading the example code
          2. Downloading the color images of this book
          3. Errata
          4. Piracy
          5. Questions
      8. 1. Why Redis?
        1. Is Redis right for me?
        2. Experimenting with Redis
        3. Popular usage patterns
        4. Redis isn't right because …try again soon!
        5. Summary
      9. 2. Advanced Key Management and Data Structures
        1. Redis keys
          1. Redis key schema
          2. Key delimiters and naming conventions
        2. Manually creating a Redis schema
        3. Deconstructing a Redis object mapper
          1. Key expiration
          2. Key cautions
        4. Big O notation
          1. Computing big O notation for custom code
        5. Reviewing the time complexity of Redis data structures
          1. Strings
          2. Hashes
          3. Lists
          4. Sets
        6. Sorted sets
        7. Advanced sorted set operations
        8. Bitstrings and bit operations
        9. HyperLogLogs
        10. Summary
      10. 3. Managing RAM – Tips and Techniques for Redis Memory Management
        1. Configuring Redis
          1. Master-slave
        2. 32-bit Redis
          1. About the INFO memory
        3. Key expiration
        4. LRU key evictions
        5. Creating memory efficient Redis data structures
          1. Small aggregate hashes, lists, sets, and sorted sets
          2. Bits, bytes, and Redis strings as random access arrays
          3. Optimizing hashes for efficient storage
        6. Hardware and network latencies
        7. Operating system tips
        8. Summary
      11. 4. Programming Redis Part One – Redis Core, Clients, and Languages
        1. Redis internals
          1. Understanding redis.h and redis.c
            1. Getting ready for Redis development with Git
            2. Exercise – creating your own redis command
          2. Redis Serialization Protocol (RESP)
            1. Pipelining
          3. Redis RDB format
        2. Coroutines using Redis and Python
          1. Todo list application using Node.js and Redis
          2. Replication and public access
        3. Summary
      12. 5. Programming Redis Part Two – Lua Scripting, Administration, and DevOps
        1. The use of Lua in Redis
        2. Using KEYS and ARGV with Redis
        3. Advanced Lua scripting with Redis
          1. MARC21 ingestion
          2. Online Storefront Paper Stationery
          3. Interoperability using JSON-LD, Lua, and Redis
          4. Redis Lua Debugger
        4. Programming Redis administration topics
          1. Master-Slave replication
          2. Transactions with MULTI and EXEC
        5. Redis role in DevOps
        6. Summary
      13. 6. Scaling with Redis Cluster and Sentinel
        1. Approaches to partitioning data
          1. Range partitioning
          2. List partitioning
          3. Hash partitioning
          4. Composite partitioning
          5. Key hash tags
        2. Clustering Redis with Twemproxy
          1. Testing Twemproxy with Linked Data Fragments server
        3. Redis Cluster background
        4. Overview of running Redis Cluster
        5. Using Redis Cluster
          1. Live reconfiguration and resharding Redis cluster
          2. Failover
          3. Replacing or upgrading nodes in Redis Cluster
        6. Monitoring with Redis Sentinel
          1. Sentinel for Area Code List Partition
        7. Summary
      14. 7. Redis and Complementary NoSQL Technologies
        1. The proliferation of NoSQL
        2. Redis as an analytics complement to MongoDB
        3. Redis as a preprocessor complement to ElasticSearch
          1. Using Redis and ElasticSearch in BIBCAT
          2. ElasticSearch, Logstash, and Redis
        4. Redis as a smart cache complement to Fedora Commons
        5. Summary
      15. 8. Docker Containers and Cloud Deployments
        1. Linux containers
        2. Docker basics with Redis
        3. Layers in Docker images
          1. Docker filesystem backends
            1. Building images with a Dockerfile
        4. Hosting and publishing Docker images
        5. Docker and Redis issues
        6. Packaging your application with Docker Compose
        7. Redis and AWS
        8. Dedicated cloud hosting options
        9. Redis Labs
          1. DigitalOcean Redis
        10. Summary
      16. 9. Task Management and Messaging Queuing
        1. Overview of Redis Pub/Sub
        2. Pub/Sub RESP replies
          1. SUBSCRIBE and UNSUBSCRIBE RESP Arrays
          2. PSUBSCRIBE and UNSUBSCRIBE arrays
          3. Pub/Sub with Redis CLI
        3. Redis Pub/Sub in action
          1. First workstation using Python Pub/Sub
          2. Second workstation Node.js Pub/Sub
          3. Third workstation Lua Client Pub/Sub
        4. Redis keyspace notifications
        5. Task management with Redis and Celery
        6. GIS and RestMQ
          1. Adding task management with RestMQ
        7. Messaging with Redis technologies
          1. Messaging with Disque
        8. Summary
      17. 10. Measuring and Managing Information Streams
        1. Extracting, transforming, and loading information with Redis
          1. Extracting JSON to transform into RESP
          2. Security considerations when managing Redis
            1. Redis protected mode
            2. Command obfuscation
            3. Operational monitoring with a Redis web dashboard
        2. Machine learning and Redis
          1. Naïve Bayes and work classification
            1. Creating training and testing datasets
            2. Extracting word Tokens from BIBFRAME Works
            3. Applying Naïve Bayes
          2. Linear regression with Redis
        3. Summary
      18. A. Sources
        1. Chapter 1: Why Redis?
        2. Chapter 2: Advanced Key Management and Data Structures
        3. Chapter 3: Managing RAM – Tips and Techniques for Redis Memory Management
        4. Chapter 6: Scaling with Redis Cluster and Sentinel
        5. Chapter 7: Redis and Complementary NoSQL Technologies
        6. Chapter 10: Measuring and Managing Information Streams
      19. Index