Cache memory makes use of replacement algorithms to evict stored elements. This is largely dependent on the cache’s architecture.
For a direct-mapped architecture, it’s trivial to decide which cache line to evict since there’s an easy correspondence between main memory and the cache. For an associative cache, this is not so easy, but we can rely on locality.