Redis is a non-relational high-performance DBMS. Redis stores all data in memory and accesses the data by key. Optionally a copy of the data can be stored on disk. This approach provides performance that is dozens of times better than relational DBMSs and simplifies data partitioning (sharding).

file

First of all, Redis knows how to save data to disk. You can set up Redis so that data is not saved at all, saved periodically by copy-on-write, or saved periodically and logged (binlog). This way you can always achieve the required balance between performance and reliability.

Redis, in contrast to Memcached, allows to store not only strings, but also arrays (which can be used as queues or stacks), dictionaries, sets without repetitions, large arrays of bits (bitmaps), and sets sorted by some value. Of course, it is possible to work with individual elements of lists, dictionaries and sets. Like Memcached, Redis allows you to specify the lifetime of the data (in two ways - "delete then" and "delete in ..."). By default, all data is stored forever.

An interesting feature of Redis is that it is a single-threaded server. This greatly simplifies code maintenance, provides atomicity of operations and allows to run one Redis process per core of the processor. Of course, each process will listen on a different port. This solution is atypical, but quite justified, since Redis spends a very small amount of time (about one hundred thousandth of a second) on a single operation.

Redis has replication. Replication with multiple master servers is not supported. Each slave server can act as a master server for others. Replication in Redis does not result in locks on either the master server or the slave servers. A write operation is allowed on replicas. When the master and slave server reconnect after a break, full synchronization (resync) occurs.

Redis also supports transactions (either all or none of the operations are sequentially executed) and batch processing of commands (execute a bunch of commands, then get a bunch of results). Moreover, nothing prevents to use them together.

Another feature of Redis is the publish/subscribe mechanism. With it, applications can create channels, subscribe to them, and put messages into the channels, which will be received by all subscribers.

Updated Sept. 17, 2018