--- a/web/lib/Zend/Cache/Backend/TwoLevels.php Thu May 07 15:10:09 2015 +0200
+++ b/web/lib/Zend/Cache/Backend/TwoLevels.php Thu May 07 15:16:02 2015 +0200
@@ -15,9 +15,9 @@
* @category Zend
* @package Zend_Cache
* @subpackage Zend_Cache_Backend
- * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
- * @version $Id: TwoLevels.php 24593 2012-01-05 20:35:02Z matthew $
+ * @version $Id$
*/
@@ -35,7 +35,7 @@
/**
* @package Zend_Cache
* @subpackage Zend_Cache_Backend
- * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
@@ -72,6 +72,11 @@
* =====> (boolean) fast_backend_autoload :
* - See Zend_Cache::factory() method
*
+ * =====> (boolean) auto_fill_fast_cache
+ * - If true, automatically fill the fast cache when a cache record was not found in fast cache, but did
+ * exist in slow cache. This can be usefull when a non-persistent cache like APC or Memcached got
+ * purged for whatever reason.
+ *
* =====> (boolean) auto_refresh_fast_cache
* - If true, auto refresh the fast cache when a cache record is hit
*
@@ -87,6 +92,7 @@
'fast_backend_custom_naming' => false,
'slow_backend_autoload' => false,
'fast_backend_autoload' => false,
+ 'auto_fill_fast_cache' => true,
'auto_refresh_fast_cache' => true
);
@@ -223,17 +229,23 @@
*/
public function load($id, $doNotTestCacheValidity = false)
{
- $res = $this->_fastBackend->load($id, $doNotTestCacheValidity);
- if ($res === false) {
- $res = $this->_slowBackend->load($id, $doNotTestCacheValidity);
- if ($res === false) {
+ $resultFast = $this->_fastBackend->load($id, $doNotTestCacheValidity);
+ if ($resultFast === false) {
+ $resultSlow = $this->_slowBackend->load($id, $doNotTestCacheValidity);
+ if ($resultSlow === false) {
// there is no cache at all for this id
return false;
}
}
- $array = unserialize($res);
+ $array = $resultFast !== false ? unserialize($resultFast) : unserialize($resultSlow);
+
+ //In case no cache entry was found in the FastCache and auto-filling is enabled, copy data to FastCache
+ if ($resultFast === false && $this->_options['auto_fill_fast_cache']) {
+ $preparedData = $this->_prepareData($array['data'], $array['lifetime'], $array['priority']);
+ $this->_fastBackend->save($preparedData, $id, array(), $array['lifetime']);
+ }
// maybe, we have to refresh the fast cache ?
- if ($this->_options['auto_refresh_fast_cache']) {
+ elseif ($this->_options['auto_refresh_fast_cache']) {
if ($array['priority'] == 10) {
// no need to refresh the fast cache with priority = 10
return $array['data'];