Index: trunk/phase3/includes/LocalisationCache.php |
— | — | @@ -159,8 +159,13 @@ |
160 | 160 | case 'db': |
161 | 161 | $storeClass = 'LCStore_DB'; |
162 | 162 | break; |
| 163 | + case 'accel': |
163 | 164 | case 'detect': |
164 | | - $storeClass = $wgCacheDirectory ? 'LCStore_CDB' : 'LCStore_DB'; |
| 165 | + if ( !( wfGetCache( CACHE_ACCEL ) instanceof FakeMemCachedClient ) ) { |
| 166 | + $storeClass = 'LCStore_Accel'; |
| 167 | + } else { |
| 168 | + $storeClass = $wgCacheDirectory ? 'LCStore_CDB' : 'LCStore_DB'; |
| 169 | + } |
165 | 170 | break; |
166 | 171 | default: |
167 | 172 | throw new MWException( |
— | — | @@ -348,7 +353,9 @@ |
349 | 354 | } |
350 | 355 | |
351 | 356 | $deps = $this->store->get( $code, 'deps' ); |
352 | | - if ( $deps === null ) { |
| 357 | + $keys = $this->store->get( $code, 'list', 'messages' ); |
| 358 | + // 'list:messages' sometimes expires separately of 'deps' in LCStore_Accel |
| 359 | + if ( $deps === null || $keys === null ) { |
353 | 360 | wfDebug( __METHOD__."($code): cache missing, need to make one\n" ); |
354 | 361 | return true; |
355 | 362 | } |
— | — | @@ -830,6 +837,54 @@ |
831 | 838 | } |
832 | 839 | |
833 | 840 | /** |
| 841 | + * LCStore implementation which uses PHP accelerator to store data. |
| 842 | + * This will work if one of XCache, eAccelerator, or APC cacher is configured. |
| 843 | + * (See ObjectCache.php) |
| 844 | + */ |
| 845 | +class LCStore_Accel implements LCStore { |
| 846 | + var $currentLang; |
| 847 | + var $keys; |
| 848 | + |
| 849 | + public function __construct() { |
| 850 | + $this->cache = wfGetCache( CACHE_ACCEL ); |
| 851 | + } |
| 852 | + |
| 853 | + public function get( $code, $key ) { |
| 854 | + $k = wfMemcKey( 'l10n', $code, 'k', $key ); |
| 855 | + return $this->cache->get( $k ); |
| 856 | + } |
| 857 | + |
| 858 | + public function startWrite( $code ) { |
| 859 | + $k = wfMemcKey( 'l10n', $code, 'l' ); |
| 860 | + $keys = $this->cache->get( $k ); |
| 861 | + if ( $keys ) { |
| 862 | + foreach ( $keys as $k ) { |
| 863 | + $this->cache->delete( $k ); |
| 864 | + } |
| 865 | + } |
| 866 | + $this->currentLang = $code; |
| 867 | + $this->keys = array(); |
| 868 | + } |
| 869 | + |
| 870 | + public function finishWrite() { |
| 871 | + if ( $this->currentLang ) { |
| 872 | + $k = wfMemcKey( 'l10n', $this->currentLang, 'l' ); |
| 873 | + $this->cache->set( $k, array_keys( $this->keys ) ); |
| 874 | + } |
| 875 | + $this->currentLang = null; |
| 876 | + $this->keys = array(); |
| 877 | + } |
| 878 | + |
| 879 | + public function set( $key, $value ) { |
| 880 | + if ( $this->currentLang ) { |
| 881 | + $k = wfMemcKey( 'l10n', $this->currentLang, 'k', $key ); |
| 882 | + $this->keys[$k] = true; |
| 883 | + $this->cache->set( $k, $value ); |
| 884 | + } |
| 885 | + } |
| 886 | +} |
| 887 | + |
| 888 | +/** |
834 | 889 | * LCStore implementation which uses the standard DB functions to store data. |
835 | 890 | * This will work on any MediaWiki installation. |
836 | 891 | */ |
— | — | @@ -1126,4 +1181,4 @@ |
1127 | 1182 | $this->unload( $code ); |
1128 | 1183 | } |
1129 | 1184 | } |
1130 | | -} |
| 1185 | +} |
\ No newline at end of file |
Index: trunk/phase3/includes/AutoLoader.php |
— | — | @@ -127,6 +127,7 @@ |
128 | 128 | 'IndexPager' => 'includes/Pager.php', |
129 | 129 | 'Interwiki' => 'includes/interwiki/Interwiki.php', |
130 | 130 | 'IP' => 'includes/IP.php', |
| 131 | + 'LCStore_Accel' => 'includes/LocalisationCache.php', |
131 | 132 | 'LCStore_CDB' => 'includes/LocalisationCache.php', |
132 | 133 | 'LCStore_DB' => 'includes/LocalisationCache.php', |
133 | 134 | 'LCStore_Null' => 'includes/LocalisationCache.php', |