Fix thread safety on snapshot cache insert