This change introduces a virtual SetCapacity method to the Cache interface, allowing the cache capacity to be adjusted dynamically. The LRUCache implementation evicts entries if the new capacity is smaller than the current usage. The ShardedLRUCache distributes the new capacity among its shards.
This functionality will be used in chromium to improve memory pressure handling. The
current Prune() functionality is not flexible enough to reduce the memory used by the
cache if necessary.
PiperOrigin-RevId: 974645811