Magento 1.x code
Mage::app()->getCacheInstance()->save($data, $key, $tags, $lifeTime);
Magento 2 code
/**
* @param string $data
* @param string $key
* @param [] $tags [optional]
* @param int|null|false $lifeTime [optional]
* @return bool
*/
function df_cache_save($data, $key, $tags = [], $lifeTime = null) {
/** @var \Magento\Framework\ObjectManagerInterface $om */
$om = \Magento\Framework\App\ObjectManager::getInstance();
/** @var \Magento\Framework\App\CacheInterface $cache */
$cache = $om->get('Magento\Framework\App\CacheInterface');
return $cache->save($data, $key, $tags, $lifeTime);
}
dmitrii_fediuk
(Dmitrii Fediuk)
Split this topic
2
A post was split to a new topic: How to cache an array?
dmitrii_fediuk
(Dmitrii Fediuk)
Split this topic
3