0

I have got some data from an API, i like to store those data to cache and update it once a day. I mean i don't like to call the API for each frontend page load. I found this function

if (!function_exists('trustedshopscachecheck')) {
    function trustedshopscachecheck($filename_cache, $timeout = 10800) {
        if (file_exists($filename_cache) && time() - filemtime($filename_cache) < $timeout)   {
            return true;
        }
        return false;
    }
}

I like to use magento cache

1 Answer 1

1

I'd choose a slightly different setup which will make the solution easier.

  • store your value as a config value in core_config_data using Magento\Framework\App\Config\Storage\WriterInterface
  • define a job in crontab.xml which overwrites this value once a day
  • when you want to access the value, simply access the configuration
3

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.