diff --git a/lib/Zend/Locale/Data.php b/lib/Zend/Locale/Data.php index c4331abd731e..f295fd01b263 100644 --- a/lib/Zend/Locale/Data.php +++ b/lib/Zend/Locale/Data.php @@ -74,6 +74,13 @@ class Zend_Locale_Data */ private static $_cacheDisabled = false; + /** + * Internal cache, prevent repeated cache requests + * + * @var array + */ + private static $_localCache = array(); + /** * Read the content from locale * @@ -335,8 +342,15 @@ public static function getList($locale, $path, $value = false) $val = urlencode($val); $id = self::_filterCacheId('Zend_LocaleL_' . $locale . '_' . $path . '_' . $val); + + // add runtime cache to avoid calling cache backend multiple times during one request + if (isset(self::$_localCache[$id])) { + return self::$_localCache[$id]; + } if (!self::$_cacheDisabled && ($result = self::$_cache->load($id))) { - return unserialize($result); + $result = unserialize($result); + self::$_localCache[$id] = $result; + return $result; } $temp = array(); @@ -946,11 +960,13 @@ public static function getList($locale, $path, $value = false) } if (isset(self::$_cache)) { + $data = serialize($temp); if (self::$_cacheTags) { - self::$_cache->save( serialize($temp), $id, array('Zend_Locale')); + self::$_cache->save( $data, $id, array('Zend_Locale')); } else { - self::$_cache->save( serialize($temp), $id); + self::$_cache->save( $data, $id); } + static::$_localCache[$id] = $temp; } return $temp; @@ -984,8 +1000,15 @@ public static function getContent($locale, $path, $value = false) } $val = urlencode($val); $id = self::_filterCacheId('Zend_LocaleC_' . $locale . '_' . $path . '_' . $val); + + // add runtime cache to avoid calling cache backend multiple times during one request + if (isset(self::$_localCache[$id])) { + return self::$_localCache[$id]; + } if (!self::$_cacheDisabled && ($result = self::$_cache->load($id))) { - return unserialize($result); + $result = unserialize($result); + self::$_localCache[$id] = $result; + return $result; } switch(strtolower($path)) { @@ -1499,11 +1522,13 @@ public static function getContent($locale, $path, $value = false) $temp = current($temp); } if (isset(self::$_cache)) { + $data = serialize($temp); if (self::$_cacheTags) { - self::$_cache->save( serialize($temp), $id, array('Zend_Locale')); + self::$_cache->save( $data, $id, array('Zend_Locale')); } else { - self::$_cache->save( serialize($temp), $id); + self::$_cache->save( $data, $id); } + static::$_localCache[$id] = $temp; } return $temp;