Home  >  Article  >  Database  >  What is the three links of redis philosophy?

What is the three links of redis philosophy?

(*-*)浩
(*-*)浩Original
2019-06-17 11:58:384256browse

The three consecutive questions of redis philosophy are the three questions asked by the examiner about redis during the interview: "What is it? Why? How to use it?".

What is the three links of redis philosophy?

These three questions require a deep understanding of redis, and the examiner does not want to hear all the answers online, but will also focus on your own understanding.

The following content comes from the Internet. (Recommended learning: Redis video tutorial)

Redis is an open source log-type, Key- Value database and provides APIs in multiple languages.

Redis is a key-value storage system. Similar to Memcached, it supports relatively more stored value types, including string (string), list (linked list), set (set), zset (sorted set - ordered set) and hash (hash type). These data types all support push/pop, add/remove, intersection, union, difference, and richer operations, and these operations are all atomic. On this basis, redis supports various different ways of sorting. Like memcached, data is cached in memory to ensure efficiency. The difference is that redis will periodically write updated data to disk or write modification operations to additional record files, and on this basis, master-slave (master-slave) synchronization is achieved.

Redis is a high-performance key-value database. The emergence of redis has largely compensated for the shortcomings of key/value storage such as memcached, and can play a very good supplementary role to relational databases in some situations. It provides Java, C/C, C#, PHP, JavaScript, Perl, Object-C, Python, Ruby, Erlang and other clients, which is very convenient to use.

Redis supports master-slave synchronization. Data can be synchronized from the master server to any number of slave servers, and the slave server can be a master server associated with other slave servers. This allows Redis to perform single-level tree replication. Saving can write data intentionally or unintentionally. Since the publish/subscribe mechanism is fully implemented, when the slave database synchronizes the tree anywhere, it can subscribe to a channel and receive the complete message release record of the master server. Synchronization is helpful for scalability and data redundancy of read operations.

1. Cache of hotspot data

Because redis has high access speed and supports rich data types, redis is very suitable for storing hotspot data. In addition, combined with expire, we can set the expiration time. Then perform the cache update operation. This function is the most common and is used in almost all of our projects.

2. Application of time-limited business

In redis, you can use the expire command to set the survival time of a key. Redis will delete it after the time is up. This feature can be used in business scenarios such as limited-time promotional information and mobile phone verification codes.

3. Issues related to counters

Since the incrby command can achieve atomic increment in redis, it can be used in high-concurrency flash sales activities and the generation of distributed serial numbers. Specific business is also reflected in For example, limit the number of text messages sent by a mobile phone number, limit the number of requests per minute by an interface, limit the number of calls per day by an interface, etc.

4. Issues related to rankings

The query speed of relational databases in rankings is generally slow, so you can use the SortedSet of redis to sort hot data.

5. Distributed lock

Of course we can apply this feature to other scenarios that require distributed locks. Combined with the expiration time, it is mainly to prevent the occurrence of deadlock.

6. Delay operation

7. Paging, fuzzy search

For more Redis related technical articles, please visit the Redis database usage tutorial column Get studying!

The above is the detailed content of What is the three links of redis philosophy?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn