Skip to content

Commit

Permalink
Add test method to cache models and fix layout update use of test met…
Browse files Browse the repository at this point in the history
…hod. (OpenMage#883)
  • Loading branch information
colinmollenhour authored Jan 20, 2020
1 parent 2e3acd9 commit 101c622
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 @@ -1187,6 +1187,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 101c622

Please sign in to comment.