Redis is the most widely used storage middleware in the field of Internet technology. It is the abbreviation of "Remote Dictionary Service", that is, "Remote Dictionary Service". Redis is widely praised in the field of open source middleware for its ultra-high performance, perfect documentation, concise and easy-to-understand source code, and rich client library support. Many large Internet companies at home and abroad are using Redis, such as Twitter, YouPorn, Blizzard Entertainment, Github, StackOverflow, Tencent, Alibaba, JD.com, Huawei, Sina Weibo, etc., and many small and medium-sized companies also have applications. It can also be said that the understanding and application practice of Redis have become essential skills for intermediate and advanced back-end developers today.
The business application range of Redis is very wide. Where can Redis be used?
1. Record the number of comments, likes and clicks (hash) of the article.
2. Record the user's article ID list (sorting) to facilitate quick display of the user's article list (zset).
3. Record the title, abstract, author and cover information of the article for list display. (hase).
4. Record the list of user IDs that like the article and the list of comment IDs for display and deduplication counting (zset).
5. Cache recent hot articles to reduce database pressure (hash).
6. Record the related article ID of the article and recommend related articles (list) based on the content.
7. If the article ID is an integer that increases automatically, you can use redis to assign the article ID (counter).
8. The relationship between collections and articles (zset).
9. Record the popular article ID list, total hot list and category hot list (zset).
10. Cache user historical behaviors and filter malicious behaviors (zset, hash).
What Redis can’t do
Redis seems to be able to do a lot of things, but it is not omnipotent. Use it in the right place to get twice the result with half the effort. If abused, it may lead to system instability, increased costs and other problems.
For example, Redis is used to save basic user information. Although it can support persistence, its persistence solution cannot guarantee the absolute landing of data, and may also cause Redis performance to decrease because of persistence. Too frequently will increase the pressure on the Redis service.
A simple summary is that businesses with too much data and very low frequency of data access are not suitable for using Redis.
If the data is too large, it will increase the cost, the access frequency is too low, and storing it in the memory is a waste of resources
The above is the detailed content of What can redis be used for?. For more information, please follow other related articles on the PHP Chinese website!