Home > Database > Redis > body text

What are the differences between local cache and redis cache?

Release: 2019-06-24 13:50:46
Original
14055 people have browsed it

What are the differences between local cache and redis cache?

The local cache and the redis cache have the following differences:

1. Reading and writing speed, regardless of concurrency issues, the local cache is naturally the fastest. But if the local cache is not locked, what should we do if it is concurrent? Therefore, we compare again in locking mode.

2. Scenario usage. The same data is taken out from the database and put into redis only once. However, putting it into the local cache requires n clusters. The local cache cannot be used for repeated clicks. Repeated clicks will be distributed. Requests are made to multiple servers, and using local cache can only prevent repeated clicks on the local machine, while redis can prevent it, but the time interval also needs to be beyond the read and write difference of redis.

3. The redis memory may be expanded n times, and the cost of expanding the heap memory locally is very high.

4. The local cache needs to implement the expiration function by itself. Poor implementation may lead to extremely serious consequences. However, redis has been verified by a large amount of traffic, and many loopholes do not require examination, so it is safe.

5. Local cache cannot provide rich data structures, but redis can. Redis can write to disk and persist, but local cache cannot or is very troublesome. There are too many things to consider.

6. Using local cache is very likely to cause serious thread safety issues, and concurrency considerations are serious. After adding local cache, the code complexity increases sharply, and it is difficult for subsequent developers to understand the original development ideas at once. Indirectly increase maintenance costs.

For more Redis-related technical articles, please visit the Redis Tutorial column to learn!

The above is the detailed content of What are the differences between local cache and redis cache?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!