Proto/Cache: Add a notion of domain to cache keys
This MR cleans up the implementation and the interface of the cache through some refactoring and documentation.
We also fix two bugs:
-
enforce_size_limit
now removes as many entries as necessary to restore the correct cache size. - In `Lazy mode, the loading of a value from a key is done only once and the result is cached. By contrast, it was done each time the value was looked up.
I am sorry that all this is done in a single commit.