Redis learning and getting started~~~

                Redis learning and getting started~~~


one. Introduction to Redis:


        Generally speaking, there are several current database classifications, including SQL/NSQL, relational database, key-value database, etc. The classification standard is not 1. Redis is also a key-value database in essence, but it maintains key While the value database is simple and fast, it also absorbs the advantages of some relational databases. Thus making its place between relational databases and key-value databases. Redis can not only save Strings type data, but also Lists type (ordered) and Sets type (unordered) data, and can also complete advanced functions such as sorting (SORT). When implementing functions such as INCR and SETNX, The atomicity of its operations is guaranteed, and in addition, functions such as master-slave replication are also supported.


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

  • Redis supports data persistence, which can save data in memory on disk, and can be loaded again for use when restarted.
  • Redis not only supports simple key-value type data, but also provides storage of data structures such as list, set, zset, and hash.
  • Redis supports data backup, that is, data backup in master-slave mode.

two. Advantages of Redis

  • Extremely high performance - Redis can read 110,000 times/s and write 81,000 times/s.
  • Rich Data Types – Redis supports Strings, Lists, Hashes, Sets and Ordered Sets data type operations for binary cases.
  • Atomic – All operations in Redis are atomic, meaning that they either execute successfully or fail to execute at all. A single operation is atomic. Transactions are also supported for multiple operations, i.e. atomicity, wrapped by MULTI and EXEC instructions.
  • Rich features - Redis also supports publish/subscribe, notifications, key expiration and more.

three. Compared:

What is Redis not? The comparison is also made from two aspects: 
1. It is not a relational database such as sql server, mySQL, etc. The main reasons are: 
     . At present, redis can only be stored as a small amount of data (all data can be loaded in memory), mass data storage Aspects are not the area that redis is good at 
     . The design and implementation methods are very different. Relational databases store data through tables and query data through SQL. Redis stores data through the above five data structures, and queries data through commands 

2. It is not a caching system such as Memcached, the main reasons are as follows 

     : .Network IO model: Memcached is multi-threaded, divided into monitor threads, worker threads, and the introduction of locks brings performance loss. Redis uses a single-threaded IO multiplexing model to maximize the speed advantage and provide simpler computing functions 
     . In terms of memory management: Memcached uses a pre-allocated memory pool, which brings a certain degree of space waste and reduces memory usage. When there is still a lot of space, new data may also be eliminated, and Redis uses on-site memory application to store data, without eliminating any non-temporary data. Redis is more suitable for storage rather than cache 
     . Data consistency: Memcached provides the cas command to ensure that. Redis provides the function of transaction, which can ensure the atomicity of a series of commands, and will not be interrupted by any operation in the middle 
     . In terms of storage method: Memcached only supports simple key-value storage, does not support Enumeration, does not support functions such as persistence and replication
   To summarize in one sentence: Redis is a high-performance key-value database. The emergence of redis has largely compensated for the insufficiency of key/value storage such as memcached, and can be a good complement to relational databases in some occasions.


Reference blog post: https://blog.csdn.net/tianzongnihao/article/details/54924924

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325726709&siteId=291194637