search

Home  >  Q&A  >  body text

php - Why is Memcached's flush_all designed to only delete keys but not values?

Not deleting the value means that the value still occupies the memory space, and without the key, the existence of these values ​​cannot be accessed. What is the significance of this?

PHP中文网PHP中文网2712 days ago561

reply all(1)I'll reply

  • 迷茫

    迷茫2017-06-12 09:22:27

    You can take a look at this article:

    Lazy Expiration

    Memcached does not internally monitor whether the record has expired. Instead, it checks the timestamp of the record when getting it to check whether the record has expired. This technique is called lazy expiration. Therefore, memcached does not consume CPU time on expiration monitoring.

    flush_all only does one thing: marks all key values ​​as expired, but does not reclaim memory. Because there was no need to reclaim memory at that time. Only when the user accesses the same key value next time, memcached checks the key value. At this time, it is found that the key value has expired, and the memory corresponding to the key value is recycled. The purpose of this is to save CPU time to the maximum extent.

    reply
    0
  • Cancelreply