Skip to content

How to store value to cache and update it once a day

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