Articles / Redis – an open source, in-memory data structure store



Redis (name means Remote Dictionary Service) is free (open source), in-memory NoSQL database, which keeps data in key-value form. Data is stored in RAM, so that it gains high efficiency. Comparing to Memcached server Redis can ensure (optionally) durability of data by writing it to the hard disk.

Redis is not typical message broker, however, it may be a substitute (alternative solution) because of its properties .

Data structures

Redis supports following data structures:

  • binary-safe strings – allowing to store text and binary data e.g. JPEG images,
  • lists, in which we can put/get data to/from the beginning (left side) or end (right side);
  • sets, which is something like a list, that has neither beginning nor end;
  • sorted sets,
  • hashes – maps composed of fields associated with values, where both the field and the value are strings;
  • bit arrays/bitmaps,
  • and others.

In addition, this NoSQL database has built-in replication mechanisms, support for Lua scripting, transactions, various types of data storage on the hard disk and provides high availability solutions via Redis Sentinel and automatic partitioning with Redis Cluster.

Use cases

The creators of this NoSQL system distinguish three basic use cases:

  • in-memory database, storing data in various structures (an alternative to relational databases);
  • cache (an alternative to Memcached server),
  • simple queue system (an alternative e.g. to RabbitMQ).

The Redis server can also be used as a layer that stores user sessions instead of a database or a Memcached server.

As a real example of the possibility of replacing the RabbitMQ message broker by Redis, one can provide Sensu – an application to monitor the server operation status, in which as the so-called transport layer you can choose one of the mentioned systems.

Tomasz Kuter

Web Developer with over 8 years of commercial experience in making websites, web applications and administration panels in PHP, JavaScript, HTML and CSS.
Currently focused on microservice architecture, which allows to build scalable web applications.