memcached expiration time

前端 未结 8 1939
面向向阳花
面向向阳花 2020-12-29 08:46

Memcached provides a cache expiration time option, which specifies how long objects are retained in the cache. Assuming all writes are through the cache I f

相关标签:
8条回答
  • 2020-12-29 09:49

    We have been thinking about the same and this is what is on memcached wiki "Even if you're actively deleting or overwriting cached data, you'll still want to have the cache expire occasionally. In case your app has a bug, a crash, a network blip, or some other issue where the cache could become out of sync."

    This makes sense as we cannot plan for network blips and it becomes important if we are releasing code every day or 2 or week. one thought we have is to restart memcached server every release, but that will get really painful if there are 10 or more memcached servers. The simplest thing I believe is to set expiry on objects.

    0 讨论(0)
  • 2020-12-29 09:50

    Expiration times are useful when you don't need precise information, you just want it to be accurate to within a certain time. So you cache your data for (say) five minutes. When the data is needed, check the cache. If it's there, use it. If not (because it expired), then go and compute the value anew.

    Some cached values are based on a large set of data, and invalidating the cache or writing new values to it is impractical. This is often true of summary data, or data computed from a large set of original data.

    0 讨论(0)
提交回复
热议问题