开发者

How long will memcached data stay in the memory

If I load the data of user_x into memory with memcache, how long will this data stay available?

If a user only logs in once a year this data is unnecessary in the memory.

开发者_高级运维

Or am i looking at this the wrong way?


memcached FAQ covers some of this.

You can set expire times up to 30 days in the future. After that memcached interprets it as a date, and will expire the item after said date. This is a simple (but obscure) mechanic.

When memcached hits its memory limit, it will automatically expire the oldest / least used entries first.

memcached uses a lazy expiration, which means it uses no extra cpu expiring items. When an item is requested (a get request) it checks the expiration time to see if the item is still valid before returning it to the client.

Similarly when adding a new item to the cache, if the cache is full, it will look at for expired items to replace before replacing the least used items in the cache.

Your cached data may be invalidated at any time because of this. As Dustin pointed out, it may also stay around forever.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜