Learning Redis

Book description

Design efficient web and business solutions with Redis

  • Model and design databases effectively in Redis

  • Learn about sharding, indexing, and migrating strategies in Redis

  • A simple step-by-step tutorial explaining the main concepts of Redis through practical examples

  • In Detail

    This book will introduce Redis and help you understand its various facets.

    Starting with an introduction to NoSQL, you will learn how to install Redis and how to classify and work with data structures. By working with real world scenarios pertaining to using Redis, you will discover sharding and indexing techniques, along with how to improve scalability and performance through persistent strategies and data migration techniques. With the help of multiple examples, you will learn to design web and business applications. You will also learn how to configure Redis for setting up clusters and tuning it for performance.

    At the end of this book, you will find essential tips on backup and recovery strategies for the Redis environment.

    What You Will Learn

  • Familiarise yourself with NoSQL and install Redis

  • Build solutions and enhance your web applications in Redis

  • Understand the persistent mechanism for better scalability

  • Configure and tune the server to improve performance

  • Identify bottlenecks and how to handle fault management in Redis

  • Learn about backups and recovery strategies for the Redis environment

  • Discover the commands and functions of Redis

  • Table of contents

    1. Learning Redis
      1. Table of Contents
      2. Learning Redis
      3. Credits
      4. About the Author
      5. About the Reviewers
      6. www.PacktPub.com
        1. Support files, eBooks, discount offers, and more
          1. Why subscribe?
          2. Free access for Packt account holders
      7. Preface
        1. What this book covers
        2. What you need for this book
        3. Who this book is for
        4. Conventions
        5. Reader feedback
        6. Customer support
          1. Downloading the example code
          2. Errata
          3. Piracy
          4. Questions
      8. 1. Introduction to NoSQL
        1. An Internet-enabled world
        2. The NoSQL primer
          1. Graph-oriented NoSQL
          2. Document-oriented NoSQL
            1. Salient features of MongoDB and CouchDB
          3. Column-oriented NoSQL
            1. Salient features of HBase and Cassandra
          4. Key value-oriented NoSQL
            1. How does Redis fare in some of the nonfunctional requirements as a key-value datastore?
            2. Use cases of NoSQL
        3. Summary
      9. 2. Getting Started with Redis
        1. Installing Redis on Windows
        2. Installing Redis on Mac OS
          1. Introduction to redis.conf
        3. Hello World in Redis
          1. Hello World using redis-cli
          2. Hello World using Java
            1. Installing Jedis and creating an environment
            2. Writing the program
            3. Shutting down the server
          3. Loading a test Hello World program in Redis
        4. Summary
      10. 3. Data Structures and Communicating Protocol in Redis
        1. Data structures
        2. Data types in Redis
          1. The string data type
          2. The BitSet or bitmap data type
            1. Use case scenario
          3. The Hashes data type
            1. Use case scenario
          4. The Lists data type
            1. Use case scenario
          5. The Sets data type
            1. Use case scenario
          6. The Sorted Sets data type
            1. Use case scenario
        3. Communication protocol – RESP
        4. Summary
      11. 4. Functions in the Redis Server
        1. Real-time messaging (PUB/SUB)
        2. Pipelines in Redis
        3. Transactions in Redis
          1. Pipeline versus transaction
          2. Pipeline and transaction
        4. Scripting in Redis
        5. Brief introduction on Lua
          1. Use case – reliable messaging
        6. Connection management
          1. Redis authentication
          2. Redis SELECT
          3. Redis ECHO and PING
        7. Summary
      12. 5. Handling Data in Redis
        1. Classifying data
        2. Master-slave data replication
          1. Setting master and slave nodes
            1. Performance pattern – high reads
            2. Performance pattern – high writes
        3. Persistence handling in Redis
          1. Persisting via the RDB option
            1. Configuring Redis for RDB persistence
            2. Use case for using RDB persistence
          2. Persisting via the AOF option
            1. Configuring Redis for AOF persistence
            2. Use case for using AOF persistence
        4. Dataset handling commands in Redis
        5. Summary
      13. 6. Redis in Web Applications
        1. Simple e-commerce – a Redis backed e-commerce site
        2. Session management
        3. Catalogue management
        4. Online analytics
          1. Implementation – simple e-commerce
          2. ProductApp
          3. UserApp
          4. RedisDBManager
          5. ProductDBManager
          6. AnalyticsDBManager
          7. ShoppingCartDBManager
          8. UserCartDBManager
        5. Summary
      14. 7. Redis in Business Applications
        1. Configuration management
          1. Gossip server
            1. Node
            2. Layered design
              1. Shell
            3. Listeners
              1. Listener manager
            4. The data handler layer
              1. JedisUtil.java
        2. Client node commands
          1. The register command
            1. Implementation of RegisterCommand
            2. Implementation of RegisterCommandHandler
          2. The activate command
            1. Implementation of ActivateCommand
            2. Implementation of ActivateCommandHandler
          3. The set command
            1. Implementation of SetCommand
            2. Implementation of SetCommandHandler
          4. The get command
            1. Implementation of GetCommand
            2. Implementation of GetCommandHandler
          5. The del command
            1. Implementation of DeleteCommand
            2. Implementation of DeleteCommandHandler
          6. The status command
            1. Implementation of StatusCommand
            2. Implementation of StatusCommandHandler
          7. The passivate command
            1. Implementation of PassivateCommand
            2. Implementation of PassivateCommandHandler
          8. The reactivate command
            1. Implementation of ReactivateCommand
            2. Implementation of ReactivateCommandHandler
          9. The archive command
            1. Implementation of ArchiveCommand
            2. Implementation of ArchiveCommandHandler
          10. The sync command
            1. Implementation of SyncCommand
            2. Implementation of SyncCommandHandler
          11. The reconnect command
            1. Implementation of ReconnectCommand
            2. Implementation of ReconnectCommandHandler
        3. Master node commands
          1. The start command
            1. Implementation of StartMasterCommand
          2. The stop command
            1. Implementation of StopMasterCommand
          3. The status command
            1. Implementation of StatusCommand
            2. Implementation of StatusCommandHandler
          4. The get command
            1. Implementation of GetNodeDataCommand
            2. Implementation of GetNodeDataCommandHandler
          5. The msg command
            1. Implementation of MessageCommand
            2. Implementation of MessageCommandHandler
          6. The kill command
            1. Implementation of KillNodeCommand
            2. Implementation of KillNodeCommandHandler
          7. The clone command
            1. Implementation of CloneNodeCommand
            2. Implementation of CloneNodeCommandHandler
        4. Redis configuration – data management
          1. The RDB option
          2. The AOF option
          3. VM overcommit memory
        5. Summary
      15. 8. Clustering
        1. Clusters
        2. Cluster pattern – master-master
          1. Performance
          2. Availability
          3. Scalability
          4. Manageability
          5. Security
          6. Drawbacks of this pattern
          7. Sharding
            1. Observations
        3. Cluster pattern – master-slave
          1. Performance
          2. Availability
          3. Scalability
          4. Manageability
          5. Security
          6. Drawbacks of this pattern
        4. Configuring Redis Sentinel
        5. Summary
      16. 9. Maintaining Redis
        1. Maintaining ephemeral data
        2. Maintaining nonephemeral data
          1. Redis 2.4
          2. Redis 2.6 to 2.8
            1. Dump and restore
            2. Snapshotting
          3. Redis 3.0
        3. Summary
      17. Index

    Product information

    • Title: Learning Redis
    • Author(s): Vinoo Das
    • Release date: June 2015
    • Publisher(s): Packt Publishing
    • ISBN: 9781783980123