I know that redis will expire the keys on its own, freeing the memory and was wondering if memcached would behave the same.
Let's say I have a kind of cache keys that are expired very rarely
(we'll call them A), and another kind that expires every 5 minutes,
using Ruby on Rails' expires_in: 5.minutes
(we'll call them B)
Will memcached drop the A keys if there are too many B keys ?
For instance if I can store 5 values in my store, a scenario could be:
- Store A1 (4 values left)
- Store B1 (3 values left)
- Store B2 (2 values left)
- Store B3 (1 values left)
- Store B4 (0 values left)
At this point B1, B2 and B3 are expired (because their lifecycle is so short).
What happens if I store another element in the cache ? Will it drop A1 since it's the oldest, or will it know that B keys are short lived and use their spot in the memory first ?