ui: Refactor cache manager to isolate API calls
ui: Refactor cache manager to isolate API calls

- Isolate all calls to the 'Cache' API to a handful of functions
  at the top of the file. This will allow those calls to be wrapped
  and exceptions handled/ignored in a follow up.
- Avoid calling await in a loop where possible instead use Promise.all()
  to wait for all the promises at once.
- Clean up a few small edge cases (for example if a cached item
  was missing the 'expires' datetime when retrieved it would never
  be deleted and take up space in the cache forever).
- Tweak comments to better match the style of the rest of the codebase

Bug: 227785665
Change-Id: I9b766f77f6dc7cda7ff86a7dc01e330432ba036b
google/perfetto,google/perfetto,google/perfetto,google/perfetto,google/perfetto,google/perfetto,google/perfetto,google/perfetto