Avoid unnecessary synchronization in ContextCache, plus forward-ported polishing

Issue: SPR-12409