I have a scenario where I save a variable to the core_config_data table using an \Magento\Config\Model\ResourceModel\Config object:
$this->_resourceConfig->saveConfig(
'mycompany/configuration/token',
$token,
'default',
0
);
then I clean the cache using \Magento\Framework\App\Cache\Manager and Magento\Framework\App\Cache\Type\Config objects:
$this->_cacheManager->clean([CacheTypeConfig::TYPE_IDENTIFIER]);
Immediately, I redirect to another page that recalls the the same config variable, but it's null.
How do we make sure the cache cleaning finished before trying to read config data?