Index: trunk/phase3/includes/LocalisationCache.php |
— | — | @@ -159,8 +159,16 @@ |
160 | 160 | case 'db': |
161 | 161 | $storeClass = 'LCStore_DB'; |
162 | 162 | break; |
| 163 | + case 'accel': |
| 164 | + $storeClass = 'LCStore_Accel'; |
| 165 | + break; |
163 | 166 | case 'detect': |
164 | | - $storeClass = $wgCacheDirectory ? 'LCStore_CDB' : 'LCStore_DB'; |
| 167 | + try { |
| 168 | + $c = wfGetCache( CACHE_ACCEL ); |
| 169 | + $storeClass = 'LCStore_Accel'; |
| 170 | + } catch( Exception $c ) { |
| 171 | + $storeClass = $wgCacheDirectory ? 'LCStore_CDB' : 'LCStore_DB'; |
| 172 | + } |
165 | 173 | break; |
166 | 174 | default: |
167 | 175 | throw new MWException( |
— | — | @@ -348,7 +356,9 @@ |
349 | 357 | } |
350 | 358 | |
351 | 359 | $deps = $this->store->get( $code, 'deps' ); |
352 | | - if ( $deps === null ) { |
| 360 | + $keys = $this->store->get( $code, 'list', 'messages' ); |
| 361 | + // 'list:messages' sometimes expires separately of 'deps' in LCStore_Accel |
| 362 | + if ( $deps === null || $keys === null ) { |
353 | 363 | wfDebug( __METHOD__."($code): cache missing, need to make one\n" ); |
354 | 364 | return true; |
355 | 365 | } |
— | — | @@ -830,6 +840,56 @@ |
831 | 841 | } |
832 | 842 | |
833 | 843 | /** |
| 844 | + * LCStore implementation which uses PHP accelerator to store data. |
| 845 | + * This will work if one of XCache, eAccelerator, or APC cacher is configured. |
| 846 | + * (See ObjectCache.php) |
| 847 | + */ |
| 848 | +class LCStore_Accel implements LCStore { |
| 849 | + var $currentLang; |
| 850 | + var $keys; |
| 851 | + |
| 852 | + public function __construct() { |
| 853 | + $this->cache = wfGetCache( CACHE_ACCEL ); |
| 854 | + } |
| 855 | + |
| 856 | + public function get( $code, $key ) { |
| 857 | + $k = wfMemcKey( 'l10n', $code, 'k', $key ); |
| 858 | + $r = $this->cache->get( $k ); |
| 859 | + if ( $r === false ) return null; |
| 860 | + return $r; |
| 861 | + } |
| 862 | + |
| 863 | + public function startWrite( $code ) { |
| 864 | + $k = wfMemcKey( 'l10n', $code, 'l' ); |
| 865 | + $keys = $this->cache->get( $k ); |
| 866 | + if ( $keys ) { |
| 867 | + foreach ( $keys as $k ) { |
| 868 | + $this->cache->delete( $k ); |
| 869 | + } |
| 870 | + } |
| 871 | + $this->currentLang = $code; |
| 872 | + $this->keys = array(); |
| 873 | + } |
| 874 | + |
| 875 | + public function finishWrite() { |
| 876 | + if ( $this->currentLang ) { |
| 877 | + $k = wfMemcKey( 'l10n', $this->currentLang, 'l' ); |
| 878 | + $this->cache->set( $k, array_keys( $this->keys ) ); |
| 879 | + } |
| 880 | + $this->currentLang = null; |
| 881 | + $this->keys = array(); |
| 882 | + } |
| 883 | + |
| 884 | + public function set( $key, $value ) { |
| 885 | + if ( $this->currentLang ) { |
| 886 | + $k = wfMemcKey( 'l10n', $this->currentLang, 'k', $key ); |
| 887 | + $this->keys[$k] = true; |
| 888 | + $this->cache->set( $k, $value ); |
| 889 | + } |
| 890 | + } |
| 891 | +} |
| 892 | + |
| 893 | +/** |
834 | 894 | * LCStore implementation which uses the standard DB functions to store data. |
835 | 895 | * This will work on any MediaWiki installation. |
836 | 896 | */ |
— | — | @@ -1126,4 +1186,4 @@ |
1127 | 1187 | $this->unload( $code ); |
1128 | 1188 | } |
1129 | 1189 | } |
1130 | | -} |
| 1190 | +} |
\ 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', |