1.1 introduction of Redis

Redis is a high performance (NOSQL) key-value database,Redis is an open source using ANSI C language, network support, memory based and persistent logging, key-value database, and provides a variety of language API. As of March 15, 2010, the development of Redis is hosted by VMware. Development of Redis has been sponsored by Pivotal since May 2013. (Vmware is funding the development and maintenance of the Redis project)

BSD stands for “Berkeley Software Distribution”, which stands for “Berkeley Software Distribution”. The BSD open source protocol is a protocol that gives users a lot of freedom. You can use it freely, modify the source code, or re-distribute the modified code as open source or proprietary software. BSD code encourages code sharing, but the author’s copyright is respected. BSD is a business-integration-friendly protocol because it allows consumers to modify and redistribute code, as well as to use or develop commercial software distribution and sales on BSD code.

1.2. Redis authors

The author of Redis, Salvatore Sanfilippo, originally from Sicily, Italy, now lives in Catania. He is currently with Pivotal.



Antirez.com, of course, can also go to follow his lot, the address is http://github.com/antirez.

1.3. No introduction

NoSQL refers to a non-relational database. With the rise of the Internet web2.0 website, the traditional relational database has been unable to cope with the web2.0 website, especially the super large scale and high concurrency SNS type web2.0 pure dynamic website, exposing a lot of problems that are difficult to overcome, while the non-relational database has been very rapid development because of its own characteristics. The creation of NoSQL database is to solve the challenges brought by large-scale data sets and multiple data types, especially the problems of big data application.

1.3.1. Four categories of NoSQL database

  • Key-values store databases

This type of database mainly uses a hash table, which has a specific key and a pointer to a specific data. The advantage of the Key/ Value model for IT systems lies in its simplicity and ease of deployment. However, if the DBA queries or updates only part of the value, the Key/value becomes inefficient. [3] For example: Tokyo Cabinet/Tyrant, Redis, Voldemort, Oracle BDB.

  • Column storage database

This part of the database is usually used to deal with large amounts of data in distributed storage. Keys still exist, but they have the characteristic of pointing to multiple columns. The columns are arranged by the column family. For example, Cassandra, HBase, Riak.

  • Document database

The document database was inspired by the Lotus Notes office software and is similar to the first type of key-value store. This type of data model is versioned documents, with semi-structured documents stored in a specific format, such as JSON. The document database can be considered an updated version of the key-value database, allowing for nested keys. And the query efficiency of document database is higher than key-value database. For example: CouchDB, MongoDb. There is also a domestic document database SequoiaDB, has been open source.

  • Graph database

Unlike other columns and SQL databases with rigid structures, a graphically structured database uses a flexible graphical model and can be scaled to multiple servers. NoSQL databases do not have a standard query language (SQL), so data models are required to perform database queries. Many NoSQL databases have REST-style data interfaces or query apis. [2] For example, Neo4J, InfoGrid, Infinite Graph.

Therefore, we conclude that NoSQL databases are suitable for the following situations:

1. The data model is relatively simple;

2. Need more flexible IT systems;

3, high requirements for database performance;

4. High data consistency is not required;

5. Environments where complex values are easier to map for a given key.

Redis and other key-value caching products have the following three characteristics:

• Redis supports persistence of data and can save data in memory to disk, which can be reloaded for use upon restart. • Redis not only supports simple key-value data, but also provides the storage of list, set, zset, hash and other data structures. • Redis supports data backup, clustering and other high availability features.

1.4. Features:

• High performance — Redis can read 110,000 times /s and write 81,000 times /s. • Rich data types – Redis supports String, List, Hash, Set, and Ordered Set data type operations. • Atomic – All operations in Redis are atomic, meaning that they either succeed or fail at all. Individual operations are atomic. Multiple operations also support transactions, namely atomicity, wrapped in MULTI and EXEC instructions. • Rich features – Redis also supports publish/subscribe, notifications, key expiration, and more.

Redis is a simple, efficient, distributed, memory – based caching tool.

After the server is set up, it provides key-value caching service through network connection (similar to database).

Redis is characterized by simplicity.

Simplicity ensures stability and excellence in core functionality.

1.5. Redis summary

Redis a single key in the 512 m size redis support multiple types of data structures (string, list, hash. Set. Zset) redis is a single-threaded atomic redis persistence Because of using the support mechanism of RDB and AOF redis cluster And Redis support library (0-15) 16 libraries redis can also do message queues such as chat room IM

In enterprise development: Can be used as a database, cache (hot data (data that is often queried, but not often modified or deleted), messaging middleware and most other functions.

  • Advantages:
  1. 2. High-speed read and write, Redis uses its own separator, the code is very short, without lock (MySQL), so the efficiency is very high.
  • Disadvantages:
  1. Persistence. Redis stores the data directly in memory, and to save the data to disk, Redis can implement the persistence process in two ways. Periodic snapshot: Writes the entire database to disk at intervals. All data is written each time, which costs a lot. The second method is based on statement appending (AOF) : only the changed data is tracked, but the appending log may be too large, and all operations are re-executed, resulting in slow recovery.
  2. Memory consumption is too high.