Skip to content

Commit

Permalink
master cache enable check
Browse files Browse the repository at this point in the history
  • Loading branch information
Fantus committed Mar 10, 2017
1 parent 0e8fdef commit acb596b
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions app/code/community/Styla/Connect/Model/Styla/Api/Cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ class Styla_Connect_Model_Styla_Api_Cache
protected $_cache;
protected $_api;

/** @var boolean */
protected $enabled;


/**
* Is this cache type enabled
Expand All @@ -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;
}

/**
Expand All @@ -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);

Expand All @@ -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);
}

Expand Down

0 comments on commit acb596b

Please sign in to comment.