Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Redis Essentials
Redis Essentials

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

Arrow left icon
Profile Icon Maxwell Dayvson da Silva
Arrow right icon
€17.99 €26.99
Full star icon Full star icon Full star icon Full star icon Half star icon 4.6 (18 Ratings)
eBook Sep 2015 230 pages 1st Edition
eBook
€17.99 €26.99
Paperback
€32.99
Subscription
Free Trial
Renews at €18.99p/m
Arrow left icon
Profile Icon Maxwell Dayvson da Silva
Arrow right icon
€17.99 €26.99
Full star icon Full star icon Full star icon Full star icon Half star icon 4.6 (18 Ratings)
eBook Sep 2015 230 pages 1st Edition
eBook
€17.99 €26.99
Paperback
€32.99
Subscription
Free Trial
Renews at €18.99p/m
eBook
€17.99 €26.99
Paperback
€32.99
Subscription
Free Trial
Renews at €18.99p/m

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
OR
Modal Close icon
Payment Processing...
tick Completed

Billing Address

Table of content icon View table of contents Preview book icon Preview Book

Redis Essentials

Chapter 2. Advanced Data Types (Earning a Black Belt)

This chapter introduces the Set, Sorted Set, Bitmap, and HyperLogLog data types. It is a continuation from the previous chapter, and it also introduces new commands through redis-cli and Node.js, along with some details of the internals of each data type.

Sets

A Set in Redis is an unordered collection of distinct Strings—it's not possible to add repeated elements to a Set. Internally, a Set is implemented as a hash table, which is the reason that some operations are optimized: member addition, removal, and lookup run in O(1), constant time.

The Set memory footprint will be reduced if all the members are integers, and the total number of elements can be as high as the value of the set-max-intset-entries configuration. Chapter 4, Commands (Where the Wild Things Are), provides more details about this configuration.

The maximum number of elements that a Set can hold is 232-1, which means that there can be more than 4 billion elements per Set.

Some use cases for Sets are:

  • Data filtering: For example, filtering all flights that depart from a given city and arrive in another
  • Data grouping: Grouping all users who viewed similar products (for example, recommendations on Amazon.com)
  • Membership checking: Checking whether a user is on a blacklist...

Sorted Sets

A Sorted Set is very similar to a Set, but each element of a Sorted Set has an associated score. In other words, a Sorted Set is a collection of nonrepeating Strings sorted by score. It is possible to have elements with repeated scores. In this case, the repeated elements are ordered lexicographically (in alphabetical order).

Sorted Set operations are fast, but not as fast as Set operations, because the scores need to be compared. Adding, removing, and updating an item in a Sorted Set runs in logarithmic time, O(log(N)), where N is the number of elements in a Sorted Set. Internally, Sorted Sets are implemented as two separate data structures:

  • A skip list with a hash table. A skip list is a data structure that allows fast search within an ordered sequence of elements.
  • A ziplist, based on the zset-max-ziplist-entries and zset-max-ziplist-value configurations.

    Note

    Chapter 4, Commands (Where the Wild Things Are), provides more details about these configurations.

Sorted Sets could be...

Bitmaps

A Bitmap is not a real data type in Redis. Under the hood, a Bitmap is a String. We can also say that a Bitmap is a set of bit operations on a String. However, we are going to consider them as data types because Redis provides commands to manipulate Strings as Bitmaps. Bitmaps are also known as bit arrays or bitsets.

A Bitmap is a sequence of bits where each bit can store 0 or 1. You can think of a Bitmap as an array of ones and zeroes. The Redis documentation refers to Bitmap indices as offsets. The application domain dictates what each Bitmap index means.

Bitmaps are memory efficient, support fast data lookups, and can store up to 232 bits (more than 4 billion bits).

See this example of a Bitmap with three bits turned on and two turned off:

Bitmaps

A Bitmap with one Set on offsets 0, 3, and 4 and zero Set on offsets 1 and 2

In order to see how a Bitmap can be memory efficient, we are going to compare a Bitmap to a Set. The comparison scenario is an application that needs to store all user...

HyperLogLogs

A HyperLogLog is not actually a real data type in Redis. Conceptually, a HyperLogLog is an algorithm that uses randomization in order to provide a very good approximation of the number of unique elements that exist in a Set. It is fascinating because it only runs in O(1), constant time, and uses a very small amount of memory—up to 12 kB of memory per key. Although technically a HyperLogLog is not a real data type, we are going to consider it as one because Redis provides specific commands to manipulate Strings in order to calculate the cardinality of a set using the HyperLogLog algorithm.

The HyperLogLog algorithm is probabilistic, which means that it does not ensure 100 percent accuracy. The Redis implementation of the HyperLogLog has a standard error of 0.81 percent. In theory, there is no practical limit for the cardinality of the sets that can be counted.

The HyperLogLog algorithm was described originally in the paper HyperLogLog: The analysis of a near-optimal cardinality...

Summary

This chapter presented advanced data types: Sets, Sorted Sets, Bitmaps, and HyperLogLogs. These were presented along with real use cases and examples using redis-cli and Node.js.

The next chapter is going to explain how to build a feature-complete Time Series system with Redis in Node.js using Strings, Hashes, and HyperLogLogs. It will support querying multiple granularities, data consolidation, and automatic data expiration.

Left arrow icon Right arrow icon

Description

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.

Who is this book 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

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Sep 08, 2015
Length: 230 pages
Edition : 1st
Language : English
ISBN-13 : 9781784396084
Languages :
Tools :

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
OR
Modal Close icon
Payment Processing...
tick Completed

Billing Address

Product Details

Publication date : Sep 08, 2015
Length: 230 pages
Edition : 1st
Language : English
ISBN-13 : 9781784396084
Languages :
Tools :

Packt Subscriptions

See our plans and pricing
Modal Close icon
€18.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
€189.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just €5 each
Feature tick icon Exclusive print discounts
€264.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just €5 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total 115.97
Redis Essentials
€32.99
Mastering Redis
€45.99
Learning Redis
€36.99
Total 115.97 Stars icon
Banner background image

Table of Contents

10 Chapters
1. Getting Started (The Baby Steps) Chevron down icon Chevron up icon
2. Advanced Data Types (Earning a Black Belt) Chevron down icon Chevron up icon
3. Time Series (A Collection of Observations) Chevron down icon Chevron up icon
4. Commands (Where the Wild Things Are) Chevron down icon Chevron up icon
5. Clients for Your Favorite Language (Become a Redis Polyglot) Chevron down icon Chevron up icon
6. Common Pitfalls (Avoiding Traps) Chevron down icon Chevron up icon
7. Security Techniques (Guard Your Data) Chevron down icon Chevron up icon
8. Scaling Redis (Beyond a Single Instance) Chevron down icon Chevron up icon
9. Redis Cluster and Redis Sentinel (Collective Intelligence) Chevron down icon Chevron up icon
Index Chevron down icon Chevron up icon

Customer reviews

Top Reviews
Rating distribution
Full star icon Full star icon Full star icon Full star icon Half star icon 4.6
(18 Ratings)
5 star 72.2%
4 star 22.2%
3 star 0%
2 star 0%
1 star 5.6%
Filter icon Filter
Top Reviews

Filter reviews by




Francisco Oct 29, 2015
Full star icon Full star icon Full star icon Full star icon Full star icon 5
This is a really good Redis book. I do have a good experience working with Redis, and was still able to profit from this book. The book goes from the very basic (installing Redis and running the first command with redis-cli) to more advanced features and techniques (using Redis as a time-series database or the inner workings of Redis Cluster and Sentinel), always with a good coverage of real-world examples.I also liked the way the authors presented the problems related to replication and sharding and then presented the official tools for that, giving a good notion on how the actual history happened, as Redis wasn't designed in the first place with replication and sharding in mind. The authors do show to have large experience in the topic, and the book is also very well written. Definitely a good book to have in the collection.
Amazon Verified review Amazon
Jim Fathman Oct 25, 2015
Full star icon Full star icon Full star icon Full star icon Full star icon 5
This is the Redis book I have been waiting for. It introduces fundamental operations using the Redis command line interface, and then shows useful examples of the same operations using Node.js. The combination of Node.js and Redis is a popular mix, so the approach in this book should appeal to a large audience of server side developers.The writing quality and editing is uncommonly good in this book. I am a fan of PACKT books which are frequently first to market for new technologies, but they are sometimes rushed and written by amateurs. Not so here. The authors and reviewers are legit, have solid technical chops, and it shows.I buy a lot of technical books from Amazon, read them, and sell them back to clear shelf space. I keep a few of the better books. This book is a keeper. I hope the authors will return with more excellent writing about other parts of the Node.js ecosystem.
Amazon Verified review Amazon
Amazon Customer Jun 07, 2017
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Lots of basic and not-so-obvious info.
Amazon Verified review Amazon
Steve L. Jan 05, 2018
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Fast delivery, would use again.
Amazon Verified review Amazon
wei lu Mar 19, 2016
Full star icon Full star icon Full star icon Full star icon Full star icon 5
I like the content, although the book cover design needs a bit work; I've been using redis for a while, it was a great read, learn bunch tricks that I didn't know, and really like couple of interesting real world examples! Thumbs up!
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

How do I buy and download an eBook? Chevron down icon Chevron up icon

Where there is an eBook version of a title available, you can buy it from the book details for that title. Add either the standalone eBook or the eBook and print book bundle to your shopping cart. Your eBook will show in your cart as a product on its own. After completing checkout and payment in the normal way, you will receive your receipt on the screen containing a link to a personalised PDF download file. This link will remain active for 30 days. You can download backup copies of the file by logging in to your account at any time.

If you already have Adobe reader installed, then clicking on the link will download and open the PDF file directly. If you don't, then save the PDF file on your machine and download the Reader to view it.

Please Note: Packt eBooks are non-returnable and non-refundable.

Packt eBook and Licensing When you buy an eBook from Packt Publishing, completing your purchase means you accept the terms of our licence agreement. Please read the full text of the agreement. In it we have tried to balance the need for the ebook to be usable for you the reader with our needs to protect the rights of us as Publishers and of our authors. In summary, the agreement says:

  • You may make copies of your eBook for your own use onto any machine
  • You may not pass copies of the eBook on to anyone else
How can I make a purchase on your website? Chevron down icon Chevron up icon

If you want to purchase a video course, eBook or Bundle (Print+eBook) please follow below steps:

  1. Register on our website using your email address and the password.
  2. Search for the title by name or ISBN using the search option.
  3. Select the title you want to purchase.
  4. Choose the format you wish to purchase the title in; if you order the Print Book, you get a free eBook copy of the same title. 
  5. Proceed with the checkout process (payment to be made using Credit Card, Debit Cart, or PayPal)
Where can I access support around an eBook? Chevron down icon Chevron up icon
  • If you experience a problem with using or installing Adobe Reader, the contact Adobe directly.
  • To view the errata for the book, see www.packtpub.com/support and view the pages for the title you have.
  • To view your account details or to download a new copy of the book go to www.packtpub.com/account
  • To contact us directly if a problem is not resolved, use www.packtpub.com/contact-us
What eBook formats do Packt support? Chevron down icon Chevron up icon

Our eBooks are currently available in a variety of formats such as PDF and ePubs. In the future, this may well change with trends and development in technology, but please note that our PDFs are not Adobe eBook Reader format, which has greater restrictions on security.

You will need to use Adobe Reader v9 or later in order to read Packt's PDF eBooks.

What are the benefits of eBooks? Chevron down icon Chevron up icon
  • You can get the information you need immediately
  • You can easily take them with you on a laptop
  • You can download them an unlimited number of times
  • You can print them out
  • They are copy-paste enabled
  • They are searchable
  • There is no password protection
  • They are lower price than print
  • They save resources and space
What is an eBook? Chevron down icon Chevron up icon

Packt eBooks are a complete electronic version of the print edition, available in PDF and ePub formats. Every piece of content down to the page numbering is the same. Because we save the costs of printing and shipping the book to you, we are able to offer eBooks at a lower cost than print editions.

When you have purchased an eBook, simply login to your account and click on the link in Your Download Area. We recommend you saving the file to your hard drive before opening it.

For optimal viewing of our eBooks, we recommend you download and install the free Adobe Reader version 9.