cache: separate metadata and blob caches
Rework the cache architecture. The cache code is now separated into
multiple classes (one for each cache type, and one global). Every cache
is now used as a context manager and must implement __getitem__ and
__setitem__ to access/update the underlying cache information.