Skip to content

Commit

Permalink
[impr-OpenMage#883] Add test method to cache models and fix layout up…
Browse files Browse the repository at this point in the history
…date test
  • Loading branch information
colinmollenhour authored and edannenberg committed Aug 17, 2020
1 parent 83b4056 commit f33bb0d
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
11 changes: 11 additions & 0 deletions app/code/core/Mage/Core/Model/App.php
Original file line number Diff line number Diff line change
Expand Up @@ -1183,6 +1183,17 @@ public function saveCache($data, $id, $tags=array(), $lifeTime=false)
return $this;
}

/**
* Test cache record availability
*
* @param string $id
* @return false|int
*/
public function testCache($id)
{
return $this->_cache->test($id);
}

/**
* Remove cache
*
Expand Down
11 changes: 11 additions & 0 deletions app/code/core/Mage/Core/Model/Cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,17 @@ public function save($data, $id, $tags = array(), $lifeTime = null)
return $this->getFrontend()->save((string)$data, $this->_id($id), $this->_tags($tags), $lifeTime);
}

/**
* Test data
*
* @param string $id
* @return false|int
*/
public function test($id)
{
return $this->getFrontend()->test($this->_id($id));
}

/**
* Remove cached data by identifier
*
Expand Down
2 changes: 1 addition & 1 deletion app/code/core/Mage/Core/Model/Layout/Update.php
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ public function saveCache()
Mage::app()->saveCache($hash, $this->getCacheId(), $tags, null);

// Only save actual XML to cache if it doesn't already exist
if ( ! Mage::app()->getCache()->test(self::XML_KEY_PREFIX . $hash)) {
if ( ! Mage::app()->testCache(self::XML_KEY_PREFIX . $hash)) {
Mage::app()->saveCache($str, self::XML_KEY_PREFIX . $hash, $tags, null);
}
return TRUE;
Expand Down

0 comments on commit f33bb0d

Please sign in to comment.