From acb596b3e36e3b50939a8cd7dd7a1d5b4ac6224d Mon Sep 17 00:00:00 2001 From: "j.krapp" Date: Fri, 10 Mar 2017 15:17:40 +0100 Subject: [PATCH] master cache enable check --- .../Styla/Connect/Model/Styla/Api/Cache.php | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/app/code/community/Styla/Connect/Model/Styla/Api/Cache.php b/app/code/community/Styla/Connect/Model/Styla/Api/Cache.php index f94bdf3..e0c8ebb 100644 --- a/app/code/community/Styla/Connect/Model/Styla/Api/Cache.php +++ b/app/code/community/Styla/Connect/Model/Styla/Api/Cache.php @@ -12,6 +12,9 @@ class Styla_Connect_Model_Styla_Api_Cache protected $_cache; protected $_api; + /** @var boolean */ + protected $enabled; + /** * Is this cache type enabled @@ -20,9 +23,11 @@ class Styla_Connect_Model_Styla_Api_Cache */ public function isEnabled() { - $useCache = Mage::app()->useCache(self::CACHE_GROUP); + if ($this->enabled === null) { + $this->enabled = Mage::app()->useCache(self::CACHE_GROUP); + } - return $useCache; + return $this->enabled; } /** @@ -34,6 +39,10 @@ public function isEnabled() */ public function save($data, $id = null, $tags = array(), $specificLifetime = false, $priority = 8) { + if (!$this->isEnabled()) { + return; + } + $tags[] = self::CACHE_TAG; $tags = array_unique($tags); @@ -52,6 +61,10 @@ public function save($data, $id = null, $tags = array(), $specificLifetime = fal */ public function load($id, $doNotTestCacheValidity = false, $doNotUnserialize = false) { + if (!$this->isEnabled()) { + return false; + } + return $this->getCache()->load($id, $doNotTestCacheValidity, $doNotUnserialize); }