# Requirement change

The team running the product-catalogue cache came by. Recency-based eviction keeps doing the
wrong thing for them: a background job sweeps a few hundred "evergreen" product ids every couple
of minutes, and those queries keep getting evicted in favor of one-off lookups that happen to land
right before the cache fills up — even though the evergreen ids are looked up constantly overall
and the one-off ones are, by definition, looked up once.

**We want an eviction rule that keeps whatever gets used the most, not whatever was used the most
recently.** Concretely:

- A new way to get a cache that evicts by frequency of use instead of recency of use. Existing
  callers must keep working exactly as before — nothing about the current cache changes.
- "Used" means exactly what it already means for the existing cache: a read, or a write to a key
  that was already there. A brand-new key starts out having been used once, by the write that
  created it.
- When the cache is full and a brand-new key needs room, the key that has been used the fewest
  times so far is the one that goes — not the one that was touched longest ago.
