2 class ObjectFileCache
extends FileCacheBase
{
4 public static function newFromKey( $key, $type ) {
7 $allowedTypes = self
::cacheableTypes();
8 if ( !isset( $allowedTypes[$type] ) ) {
9 throw new MWException( "Invalid filecache type given." );
11 $cache->mKey
= (string)$key;
12 $cache->mType
= (string)$type;
13 $cache->mExt
= $allowedTypes[$cache->mType
];
19 * Get the type => extension mapping
22 protected static function cacheableTypes() {
23 return array( 'resources-js' => 'js', 'resources-css' => 'css' );
27 * Get the base file cache directory
30 protected function cacheDirectory() {
31 global $wgCacheDirectory, $wgFileCacheDirectory, $wgFileCacheDepth;
32 if ( $wgFileCacheDirectory ) {
33 $dir = $wgFileCacheDirectory;
34 } elseif ( $wgCacheDirectory ) {
35 $dir = "$wgCacheDirectory/object";
37 throw new MWException( 'Please set $wgCacheDirectory in LocalSettings.php if you wish to use the HTML file cache' );