Redis – Introduction

Redis (REmote DIctionary Server) is an in-memory NoSQL key-value DBMS (Database Management System), it was created to catalogue information distinguishing it with a key that allows immediate recovery.

In the last few years it has established itself as one of the most used database types in the world, and the most used among the NoSQL after MongoDB (a document based DBMS & not a key-value one),
One of the reasons of this success is Redis’s ability to store and manipulate high-level data types, fundamental data structures such as: lists, maps, sets, ordered sets, expiring keys & hashes.

Thanks to it’s exceptional performance, simplicity & atomic operations Redis lends itself to solving problems that are difficult or perform poorly with any traditional relational DBMS.

 

Key Features:

open-source (BSD License).
Lightweight with no Dependencies, Redis is written C with no external dependencies. Works well in all POSIX environments. Windows is not officially supported, but there is an experimental attempt provided by Microsoft.
High Performance: Redis make usage of in-memory data to optimize performance, while still contemplating several persistent disk rescue mechanisms.
High-Level Data Structures: Redis provides five possible data types for the values associated to the keys: strings, lists, sets, hashes, and sorted sets. And handles some operations that are uniques to some data types (like setting expiration to keys, incrementing values).
UDF* functions are based on Lua scripting (yes, you can extend & use your own defined functions)
Easy to use clients, for almost every major stack (Java, PHP, C#, Python, Javascript….Etc) .
Redis Cluster is production-ready since April 1st, 2015, requiring Redis 3.0 or higher.

 

The Key/Value nature of this DMBS makes it suitable for different usages such as:

Caching, due to its high performance, many developers are using it as a cache layer to accelerate applications and reduce network bandwith, with the easiness to persist the data to disk, it becomes a good alternative to the traditional memcached.
Queuing Projects such as Resque, Kue, Sidekiq, RQ, RestMQ, Huey, Disque uses Redis as the backend for queueing background jobs.
Counters & Analytics, atomic commands such as HINCRBY, allow for a simple and thread-save implementation of counters (as there is no need to read the data before incrementing, and there are no database schemas to update).
PubSub, since Redis 2.0, it provides the capability to distribute data utilizing the Publish/Subscribe messaging paradigm.

Some big companies using Redis:

Github, one of the early adopters, Github has developed and open-sourced the Resque library, to facilitate the execution of background jobs that have been placed on a queue. More on how Github uses Redis for their job queueing needs.

Twitter deployed a massive Redis cluster to store the timelines for all users, utilizing the list data structure. View the presentation given by Twitter on how they distribute timelines at scale.

Pinterest – Stores the user follower graphs in a Redis cluster where data is sharded across hundreds of instances, the Pinterest software engineers and architects had MySQL and Memcache already in place, however the caching solution had already reached their limits, and to better serve their users the cache needed to be expanded. More on how Pinterest is using Redis.

 

 

In fine, Redis could be used as any relational DBMS thanks to the keys and various data types to persist data to disk.

This guide’s aimed to help you step by step in every major aspect of Redis, from basic interactions in the console to more advanced clustering concepts, it’s simple and you can start testing it online on try.Redis.io (in which you can find also other exercises rather than applying our examples).

 


Redis – Practical Guide

Quick & practical guide to a fantastic no-sql key/value in-memory DBMS.

From basic interactions with data via API, to some advanced configurations, in this quick course we will see the aspects that makes Redis such a fascinating database suitable for many use cases:

  1. Introduction
  2. Installation & Environment
  3. Type of Data
  4. GET & SET
  5. Strings
  6. Lists
  7. Set
  8. Hash
  9. Sorted Set
  10. Expiring keys
  11. Transactions
  12. Administration & Configuration
  13. Data Persistence
  14. Security
  15. Replication
  16. Usage in Java
  17. Usage in Node.js
  18. Usage in Python
  19. Usage in PHP
  20. From relational model to Redis
  21. an Example of a database

About

My name is Youssef Aâni. I am Lead Developer at Excess Return.

I have been involved in web development since roughly late 2006, working mostly in Java, PHP and NodeJS, but i also dabbled in Ruby, Go, Docker, bash, SQL, NO-SQL, HTML5, CSS3, Javascript, jQuery, Angular, Phonegap and other technologies.
Currently i enjoy working with those tools/frameworks/technologies as they makes my life easier: GIT, NPM, Putty, Navicat, Sublime Text, NetBeans, JetBrain’s products (specially webstorm and phpstorm)

I hope that my content in this blog helps you to fall in love with programming and technology the way it made me fall.

If you wanna get in touch, here, or use one of the icons on the sidebar.