How long memcached data is stored in memory

If I load user_x data into memory using memcache, how long will that data remain available?

If a user logs in only once a year, this data is not needed in memory.

Or am I looking at it wrong?

+4
source share
1 answer

The memcached FAQ covers some of these.

In the future, you can set the validity period to 30 days. After that memcached interprets it as a date and expires after the specified date. This is a simple (but obscure) mechanic.

When memcached reaches its memory limit, it will automatically expire from the earliest / least used item.

memcached uses lazy expiration, which means that it does not use extra expiration elements of the processor. When an item is requested (receive request), it checks the expiration time to verify that the item is valid before returning it to the client.

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

Your cached data may be canceled at any time because of this. As Dustin noted, he can also stay forever.

+5
source

Source: https://habr.com/ru/post/1305293/


All Articles