MDL-41106 cache: several fixes for the session cache.