Redis Essentials
eBook - ePub

Redis Essentials

  1. 230 pages
  2. English
  3. ePUB (mobile friendly)
  4. Available on iOS & Android
eBook - ePub
Book details
Book preview
Table of contents
Citations

About This Book

Harness the power of Redis to integrate and manage your projects efficiently

About This Book

  • Learn how to use Redis's data types efficiently to manage large data sets
  • Scale Redis to multiple servers with Twemproxy, Redis Sentinel, and Redis Cluster
  • A fast-paced guide, full of real-world examples to help you get the best out of the features offered by Redis

Who This Book Is For

If you are a competent developer with experience of working with data structure servers and want to boost your project's performance by learning about features of Redis, then this book is for you.

What You Will Learn

  • Build analytics applications using Bitmaps and Hyperloglogs
  • Enhance scalability with Twemproxy, Redis Sentinel, and Redis Cluster
  • Build a Time Series implementation in Node.js and Redis
  • Create your own Redis commands by extending Redis with Lua
  • Get to know security techniques to protect your data (SSL encryption, firewall rules, basic authorization)
  • Persist data to disk and learn the trade-offs of AOF and RDB
  • Understand how to use Node.js, PHP, Python, and Ruby clients for Redis
  • Avoid common pitfalls when designing your next solution

In Detail

Redis is the most popular in-memory key-value data store. It's very lightweight and its data types give it an edge over the other competitors. If you need an in-memory database or a high-performance cache system that is simple to use and highly scalable, Redis is what you need.

Redis Essentials is a fast-paced guide that teaches the fundamentals on data types, explains how to manage data through commands, and shares experiences from big players in the industry.

We start off by explaining the basics of Redis followed by the various data types such as Strings, hashes, lists, and more. Next, Common pitfalls for various scenarios are described, followed by solutions to ensure you do not fall into common traps.

After this, major differences between client implementations in PHP, Python, and Ruby are presented. Next, you will learn how to extend Redis with Lua, get to know security techniques such as basic authorization, firewall rules, and SSL encryption, and discover how to use Twemproxy, Redis Sentinel, and Redis Cluster to scale infrastructures horizontally. At the end of this book, you will be able to utilize all the essential features of Redis to optimize your project's performance.

Style and approach

A practical guide that offers the foundation upon which you can begin to understand the capabilities of Redis using a step-by-step approach. This book is full of real-world problems and in-depth knowledge of the concepts and features of Redis, with plenty of examples.

Frequently asked questions

Simply head over to the account section in settings and click on “Cancel Subscription” - it’s as simple as that. After you cancel, your membership will stay active for the remainder of the time you’ve paid for. Learn more here.
At the moment all of our mobile-responsive ePub books are available to download via the app. Most of our PDFs are also available to download and we're working on making the final remaining ones downloadable now. Learn more here.
Both plans give you full access to the library and all of Perlego’s features. The only differences are the price and subscription period: With the annual plan you’ll save around 30% compared to 12 months on the monthly plan.
We are an online textbook subscription service, where you can get access to an entire online library for less than the price of a single book per month. With over 1 million books across 1000+ topics, we’ve got you covered! Learn more here.
Look out for the read-aloud symbol on your next book to see if you can listen to it. The read-aloud tool reads text aloud for you, highlighting the text as it is being read. You can pause it, speed it up and slow it down. Learn more here.
Yes, you can access Redis Essentials by Maxwell Dayvson Da Silva, Hugo Lopes Tavares in PDF and/or ePUB format, as well as other popular books in Ciencia de la computación & Bases de datos. We have over one million books available in our catalogue for you to explore.

Information

Year
2015
ISBN
9781784392451

Redis Essentials


Table of Contents

Redis Essentials
Credits
About the Authors
Acknowledgments
About the Reviewers
www.PacktPub.com
Support files, eBooks, discount offers, and more
Why subscribe?
Free access for Packt account holders
Preface
What this book covers
What you need for this book
Who this book is for
Conventions
Reader feedback
Customer support
Downloading the example code
Errata
Piracy
Questions
1. Getting Started (The Baby Steps)
Installation
Installing from source
Hello Redis (command-line interface examples)
Installing Node.js
JavaScript syntax quick reference guide
Hello World with Node.js and Redis
Redis data types
Strings
String examples with redis-cli
Building a voting system with Strings using Node.js
Lists
List examples with redis-cli
Implementing a generic Queue System
Hashes
Using Hashes with redis-cli
A voting system with Hashes and Node.js
Summary
2. Advanced Data Types (Earning a Black Belt)
Sets
Set examples with redis-cli
Building a deal tracking system
Sorted Sets
Sorted Set examples with redis-cli
Building a leaderboard system for an online game
Bitmaps
Bitmap examples with redis-cli
Building web analytics
HyperLogLogs
Counting unique users – HyperLogLog versus Set
HyperLogLogs examples with redis-cli
Counting and retrieving unique website visits
Summary
3. Time Series (A Collection of Observations)
Building the foundation
Optimizing with Hashes
Adding uniqueness with Sorted Sets and HyperLogLog
Summary
4. Commands (Where the Wild Things Are)
Pub/Sub
Transactions
Pipelines
Scripting
Lua syntax basics
Redis meets Lua
Miscellaneous commands
INFO
DBSIZE
DEBUG SEGFAULT
MONITOR
CLIENT LIST and CLIENT SET NAME
CLIENT KILL
FLUSHALL
RANDOMKEY
EXPIRE and EXPIREAT
TTL and PTTL
PERSIST
SETEX
DEL
EXISTS
PING
MIGRATE
SELECT
AUTH
SCRIPT KILL
SHUTDOWN
OBJECT ENCODING
Data type optimizations
String
List
Set
Hash
Sorted Set
Measuring memory usage
Summary
5. Clients for Your Favorite Language (Become a Redis Polyglot)
PHP
The basic commands in PHP
The blocking commands in PHP
Pipelines in PHP
Transactions in PHP
Scripting in PHP
Python
The basic commands in Python
The blocking commands in Python
Pipelines in Python
Transactions in Python
Scripting in Python
Ruby
The basic commands in Ruby
The blocking commands in Ruby
Pipelines in Ruby
Transactions in Ruby
Scripting in Ruby
Summary
6. Common Pitfalls (Avoiding Traps)
The wrong data type for the job
The Set approach
The Bitmap approach
Multiple Redis databases
Keys without a namespace
Using Swap
Not planning and configuring the memory properly
An inappropriate persistence strategy
Summary
7. Security Techniques (Guard Your Data)
The basic security
Obfuscating critical commands
Networking security
Protecting Redis with firewall rules
Running Redis on the loopback network interface
Running Redis in a Virtual Private Cloud
Encrypting client-to-server communication
Running stunnel on both the server and the client
Running stunnel on the server and using a Redis client that supports SSL
Summary
8. Scaling Redis (Beyond a Single Instance)
Persistence
RDB (Redis Database)
AOF (Append-only File)
RDB versus AOF
Replication
Partitioning
Range partitioning
Hash partitioning
Presharding
Consistent hashing
Tagging
Data store versus cache
Implementations of Redis partitioning
Automatic sharding with twemproxy
Other architectures that use twemproxy
Summary
9. Redis Cluster and Redis Sentinel (Collective Intelligence)
The CAP theorem
Redis Sentinel
The basic Sentinel configuration
Connecting to Sentinel
Network partition (split-brain)
Redis Cluster
Hash slots
Hash tags
Creating a basic cluster
Finding nodes and redirects
Configuration
Different Redis Cluster architectures
Cluster administration
Creating a cluster
Adding slaves/replicas
Scaling reads using slave nodes
Adding nodes
Removing nodes
Redis Cluster administration using the redis-trib tool
Summary
Index

Redis Essentials

Copyright © 2015 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the authors, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.
First published: September 2015
Production reference: 1030915
Published by Packt Publishing Ltd.
Livery Place
35 Livery Street
Birmingham B3 2PB, UK.
ISBN 978-1-78439-245-1
www.packtpub.com

Credits

Authors
Maxwell Dayvson Da Silva
Hugo Lopes Tavares
Reviewers
Gustavo Franco
Chad Lung
Stephen McDonald
Yi Wang
Comm...

Table of contents

  1. Redis Essentials