[res] Make sure cached container is retained off cache

The object in the cache may get removed by a different thread,
so getting it from the cache needs to also take (shared)
ownership instead of relying just on the cache itself.

This CL makes the cache hols shared_ptr<> and getting it
increments the ref counter, so the object won't go away
anymore

+ fix a few small issues in Idmap - const return types
  and bad formatting

Bug: 332234677
Flag: EXEMPT bugfix
Test: build + boot
Change-Id: I8e666e380a58b45142ddbd196dd684e5874fd2a6
4 files changed