@@ -74,6 +74,13 @@ class Zend_Locale_Data
74
74
*/
75
75
private static $ _cacheDisabled = false ;
76
76
77
+ /**
78
+ * Internal cache, prevent repeated cache requests
79
+ *
80
+ * @var array
81
+ */
82
+ private static $ _localCache = array ();
83
+
77
84
/**
78
85
* Read the content from locale
79
86
*
@@ -335,8 +342,15 @@ public static function getList($locale, $path, $value = false)
335
342
336
343
$ val = urlencode ($ val );
337
344
$ id = self ::_filterCacheId ('Zend_LocaleL_ ' . $ locale . '_ ' . $ path . '_ ' . $ val );
345
+
346
+ // add runtime cache to avoid calling cache backend multiple times during one request
347
+ if (isset (self ::$ _localCache [$ id ])) {
348
+ return self ::$ _localCache [$ id ];
349
+ }
338
350
if (!self ::$ _cacheDisabled && ($ result = self ::$ _cache ->load ($ id ))) {
339
- return unserialize ($ result );
351
+ $ result = unserialize ($ result );
352
+ self ::$ _localCache [$ id ] = $ result ;
353
+ return $ result ;
340
354
}
341
355
342
356
$ temp = array ();
@@ -946,11 +960,13 @@ public static function getList($locale, $path, $value = false)
946
960
}
947
961
948
962
if (isset (self ::$ _cache )) {
963
+ $ data = serialize ($ temp );
949
964
if (self ::$ _cacheTags ) {
950
- self ::$ _cache ->save ( serialize ( $ temp ) , $ id , array ('Zend_Locale ' ));
965
+ self ::$ _cache ->save ( $ data , $ id , array ('Zend_Locale ' ));
951
966
} else {
952
- self ::$ _cache ->save ( serialize ( $ temp ) , $ id );
967
+ self ::$ _cache ->save ( $ data , $ id );
953
968
}
969
+ static ::$ _localCache [$ id ] = $ temp ;
954
970
}
955
971
956
972
return $ temp ;
@@ -984,8 +1000,15 @@ public static function getContent($locale, $path, $value = false)
984
1000
}
985
1001
$ val = urlencode ($ val );
986
1002
$ id = self ::_filterCacheId ('Zend_LocaleC_ ' . $ locale . '_ ' . $ path . '_ ' . $ val );
1003
+
1004
+ // add runtime cache to avoid calling cache backend multiple times during one request
1005
+ if (isset (self ::$ _localCache [$ id ])) {
1006
+ return self ::$ _localCache [$ id ];
1007
+ }
987
1008
if (!self ::$ _cacheDisabled && ($ result = self ::$ _cache ->load ($ id ))) {
988
- return unserialize ($ result );
1009
+ $ result = unserialize ($ result );
1010
+ self ::$ _localCache [$ id ] = $ result ;
1011
+ return $ result ;
989
1012
}
990
1013
991
1014
switch (strtolower ($ path )) {
@@ -1499,11 +1522,13 @@ public static function getContent($locale, $path, $value = false)
1499
1522
$ temp = current ($ temp );
1500
1523
}
1501
1524
if (isset (self ::$ _cache )) {
1525
+ $ data = serialize ($ temp );
1502
1526
if (self ::$ _cacheTags ) {
1503
- self ::$ _cache ->save ( serialize ( $ temp ) , $ id , array ('Zend_Locale ' ));
1527
+ self ::$ _cache ->save ( $ data , $ id , array ('Zend_Locale ' ));
1504
1528
} else {
1505
- self ::$ _cache ->save ( serialize ( $ temp ) , $ id );
1529
+ self ::$ _cache ->save ( $ data , $ id );
1506
1530
}
1531
+ static ::$ _localCache [$ id ] = $ temp ;
1507
1532
}
1508
1533
1509
1534
return $ temp ;
0 commit comments