Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The difference between redis and memcached

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

Simply comparing Redis with Memcached, most people will get the following idea:

1 Redis not only supports simple k/v type data, but also provides storage of list, set, hash and other data structures.

2 Redis supports data backup, namely master-slave mode data backup.

3 Redis supports data persistence, can keep the data in memory in disk, restart time can be loaded again for use.

Despite this, you can dive into the internal structure of Redis to observe more essential differences and understand the design of Redis.

In Redis, not all data is always stored in memory. This is the biggest difference between Memcached and Memcached. Redis will only cache all key information. If Redis finds that the memory usage exceeds a certain threshold, it will trigger swap operation. Redis calculates which key corresponding values need to be swapped to disk according to "swappability = age*log(size_in_memory)". Then persist the values corresponding to these keys to disk and clear them in memory.

This feature allows Redis to hold data that exceeds the size of the machine's own memory. Of course, the memory of the machine itself must be able to hold all the keys, after all, these data will not swap operations. At the same time, because Redis swaps the data in memory to disk, the main thread providing the service and the child thread performing the swap operation will share this part of memory, so if the data that needs swap is updated, Redis will block this operation until the child thread completes the swap operation.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report