Chapter 1. Getting Started (The Baby Steps)
Redis is a NoSQL (Not only SQL) advanced key-value data store. It is also referred to as a data structure server because of its powerful data types, such as Strings, Hashes, Lists, Sets, Sorted Sets, Bitmaps, and HyperLogLogs. By default, Redis saves all data in the memory, therefore read and write operations are very fast. It can also cause data to persist in the disk. Data persistence in Redis can be achieved by creating a binary snapshot of the stored data or a human-readable file with a sequence of all executed commands over time. These are respectively known as snapshotting and journaling.
Additionally, Redis includes configurable key expiration, transactions, and publish/subscribe features. It also provides Lua scripting to extend Redis to create new commands. Combined, these features transform Redis into the Swiss Army knife of data type storage.
Redis stands for REmote DIctionary Server. It was written in C by Salvatore Sanfilippo in 2006 and currently has many contributors. There are Redis clients available for over 30 programming languages. The open source project can be found at https://github.com/antirez/redis. The official Redis documentation is also a really good resource of knowledge and can be found at http://redis.io.
Redis is a well-established open source project and has been used in production for years by big companies, including Twitter, GitHub, Tumblr, Pinterest, Instagram, Hulu, Flickr, and The New York Times.
This chapter is going to show you how to install Redis, introduce the command-line interface, introduce a Node.js client for Redis, and then present three data types in detail: Strings, Lists, and Hashes.
Redis data types are a very extensive subject. There is enough information to write a book that just describes how they work. We will present the most relevant and useful commands for each data type along with real-life use cases in the first two chapters. Chapter 2, Advanced Data Types (Earning a Black Belt), is going to cover other data types: Sets, Sorted Sets, Bitmaps, and HyperLogLogs. After this chapter and the next have explained all data types, Chapter 3, Time Series (A Collection of Observations), will present a time series implementation that uses multiple data types.
Note
Please note that all data types will be shown with the first letter capitalized (for example, Strings, Lists, Bitmaps, Sets, Sorted Sets, and HyperLogLogs) so that we can distinguish between a Redis data type and other existing terms.