@@ -74,6 +74,13 @@ class Zend_Locale_Data
7474 */
7575 private static $ _cacheDisabled = false ;
7676
77+ /**
78+ * Internal cache, prevent repeated cache requests
79+ *
80+ * @var array
81+ */
82+ private static $ _localCache = array ();
83+
7784 /**
7885 * Read the content from locale
7986 *
@@ -335,8 +342,15 @@ public static function getList($locale, $path, $value = false)
335342
336343 $ val = urlencode ($ val );
337344 $ id = self ::_filterCacheId ('Zend_LocaleL_ ' . $ locale . '_ ' . $ path . '_ ' . $ val );
345+
346+ // add runtime cache to avoid callng cache backend multiple times during one request
347+ if ( isset (self ::$ _localCache [$ id ])) {
348+ return self ::$ _localCache [$ id ];
349+ }
338350 if (!self ::$ _cacheDisabled && ($ result = self ::$ _cache ->load ($ id ))) {
339- return unserialize ($ result );
351+ $ result = unserialize ($ result );
352+ self ::$ _localCache [$ id ] = $ result ;
353+ return $ result ;
340354 }
341355
342356 $ temp = array ();
@@ -946,11 +960,13 @@ public static function getList($locale, $path, $value = false)
946960 }
947961
948962 if (isset (self ::$ _cache )) {
963+ $ data = serialize ($ temp );
949964 if (self ::$ _cacheTags ) {
950- self ::$ _cache ->save ( serialize ( $ temp ) , $ id , array ('Zend_Locale ' ));
965+ self ::$ _cache ->save ( $ data , $ id , array ('Zend_Locale ' ));
951966 } else {
952- self ::$ _cache ->save ( serialize ( $ temp ) , $ id );
967+ self ::$ _cache ->save ( $ data , $ id );
953968 }
969+ static ::$ _localCache ['id ' ] = $ data ;
954970 }
955971
956972 return $ temp ;
@@ -985,7 +1001,9 @@ public static function getContent($locale, $path, $value = false)
9851001 $ val = urlencode ($ val );
9861002 $ id = self ::_filterCacheId ('Zend_LocaleC_ ' . $ locale . '_ ' . $ path . '_ ' . $ val );
9871003 if (!self ::$ _cacheDisabled && ($ result = self ::$ _cache ->load ($ id ))) {
988- return unserialize ($ result );
1004+ $ result = unserialize ($ result );
1005+ self ::$ _localCache [$ id ] = $ result ;
1006+ return $ result ;
9891007 }
9901008
9911009 switch (strtolower ($ path )) {
@@ -1499,11 +1517,13 @@ public static function getContent($locale, $path, $value = false)
14991517 $ temp = current ($ temp );
15001518 }
15011519 if (isset (self ::$ _cache )) {
1520+ $ data = serialize ($ temp );
15021521 if (self ::$ _cacheTags ) {
1503- self ::$ _cache ->save ( serialize ( $ temp ) , $ id , array ('Zend_Locale ' ));
1522+ self ::$ _cache ->save ( $ data , $ id , array ('Zend_Locale ' ));
15041523 } else {
1505- self ::$ _cache ->save ( serialize ( $ temp ) , $ id );
1524+ self ::$ _cache ->save ( $ data , $ id );
15061525 }
1526+ static ::$ _localCache ['id ' ] = $ data ;
15071527 }
15081528
15091529 return $ temp ;
0 commit comments