MediaWiki  1.28.0
HTMLFileCache Class Reference

Page view caching in the file system. More...

Inheritance diagram for HTMLFileCache:
Collaboration diagram for HTMLFileCache:

Public Member Functions

 __construct ($title, $action)
 
 loadFromFileCache (IContextSource $context, $mode=self::MODE_NORMAL)
 Read from cache to context output. More...
 
 saveToFileCache ($text)
 Save this cache object with the given text. More...
 
- Public Member Functions inherited from FileCacheBase
 cacheTimestamp ()
 Get the last-modified timestamp of the cache file. More...
 
 clearCache ()
 Clear the cache for this page. More...
 
 fetchText ()
 Get the uncompressed text from the cache. More...
 
 getMissesRecent ()
 Roughly gets the cache misses in the last hour by unique visitors. More...
 
 incrMissesRecent (WebRequest $request)
 Roughly increments the cache misses in the last hour by unique visitors. More...
 
 isCached ()
 Check if the cache file exists. More...
 
 isCacheGood ($timestamp= '')
 Check if up to date cache file exists. More...
 
 saveText ($text)
 Save and compress text to the cache. More...
 

Static Public Member Functions

static clearFileCache (Title $title)
 Clear the file caches for a page for all actions. More...
 
static newFromTitle ($title, $action)
 Construct an HTMLFileCache object from a Title and an action. More...
 
static useFileCache (IContextSource $context, $mode=self::MODE_NORMAL)
 Check if pages can be cached for this request/user. More...
 

Public Attributes

const MODE_NORMAL = 0
 
const MODE_OUTAGE = 1
 
const MODE_REBUILD = 2
 
- Public Attributes inherited from FileCacheBase
const MISS_FACTOR = 15
 
const MISS_TTL_SEC = 3600
 

Protected Member Functions

 cacheDirectory ()
 Get the base file cache directory. More...
 
 typeSubdirectory ()
 Get the cache type subdirectory (with the trailing slash) or the empty string Alter the type -> directory mapping to put action=view cache at the root. More...
 
- Protected Member Functions inherited from FileCacheBase
 __construct ()
 
 baseCacheDirectory ()
 Get the base file cache directory. More...
 
 cacheDirectory ()
 Get the base cache directory (not specific to this file) More...
 
 cacheMissKey ()
 
 cachePath ()
 Get the path to the cache file. More...
 
 checkCacheDirs ()
 Create parent directors of $this->cachePath() More...
 
 hashSubdirectory ()
 Return relative multi-level hash subdirectory (with trailing slash) or the empty string if not $wgFileCacheDepth. More...
 
 typeSubdirectory ()
 Get the cache type subdirectory (with trailing slash) An extending class could use that method to alter the type -> directory mapping. More...
 
 useGzip ()
 Check if the cache is gzipped. More...
 

Static Protected Member Functions

static cacheablePageActions ()
 Cacheable actions. More...
 

Additional Inherited Members

- Protected Attributes inherited from FileCacheBase
 $mCached
 
 $mExt = 'cache'
 
 $mFilePath
 
 $mKey
 
 $mType = 'object'
 
 $mUseGzip
 

Detailed Description

Page view caching in the file system.

The only cacheable actions are "view" and "history". Also special pages will not be cached.

Definition at line 33 of file HTMLFileCache.php.

Constructor & Destructor Documentation

HTMLFileCache::__construct (   $title,
  $action 
)
Parameters
Title | string$titleTitle object or prefixed DB key string
string$action
Exceptions
MWException

Definition at line 56 of file HTMLFileCache.php.

References $title, and string.

Member Function Documentation

static HTMLFileCache::cacheablePageActions ( )
staticprotected

Cacheable actions.

Returns
array

Definition at line 74 of file HTMLFileCache.php.

HTMLFileCache::cacheDirectory ( )
protected

Get the base file cache directory.

Returns
string

Definition at line 82 of file HTMLFileCache.php.

References FileCacheBase\baseCacheDirectory().

static HTMLFileCache::clearFileCache ( Title  $title)
static

Clear the file caches for a page for all actions.

Parameters
Title$title
Returns
bool Whether $wgUseFileCache is enabled

Definition at line 245 of file HTMLFileCache.php.

References $title, $type, and as.

Referenced by WikiPage\doPurge(), HTMLCacheUpdateJob\invalidateTitles(), WikiPage\onArticleDelete(), and WikiPage\onArticleEdit().

HTMLFileCache::loadFromFileCache ( IContextSource  $context,
  $mode = self::MODE_NORMAL 
)

Read from cache to context output.

Parameters
IContextSource$context
integer$modeOne of the HTMLFileCache::MODE_* constants
Returns
void

Definition at line 159 of file HTMLFileCache.php.

References $wgContLang, FileCacheBase\cachePath(), IContextSource\getOutput(), IContextSource\getTitle(), global, FileCacheBase\useGzip(), wfClientAcceptsGzip(), and wfDebug().

static HTMLFileCache::newFromTitle (   $title,
  $action 
)
static

Construct an HTMLFileCache object from a Title and an action.

Deprecated:
since 1.24, instantiate this class directly
Parameters
Title | string$titleTitle object or prefixed DB key string
string$action
Exceptions
MWException
Returns
HTMLFileCache

Definition at line 47 of file HTMLFileCache.php.

References $title.

HTMLFileCache::saveToFileCache (   $text)

Save this cache object with the given text.

Use this as an ob_start() handler.

Normally this is only registed as a handler if $wgUseFileCache is on. If can be explicitly called by rebuildFileCache.php when it takes over handling file caching itself, disabling any automatic handling the the process.

Parameters
string$text
Returns
string|bool The annotated $text or false on error

Definition at line 202 of file HTMLFileCache.php.

References FileCacheBase\saveText(), FileCacheBase\useGzip(), wfClientAcceptsGzip(), wfDebug(), and wfTimestampNow().

HTMLFileCache::typeSubdirectory ( )
protected

Get the cache type subdirectory (with the trailing slash) or the empty string Alter the type -> directory mapping to put action=view cache at the root.

Returns
string

Definition at line 92 of file HTMLFileCache.php.

static HTMLFileCache::useFileCache ( IContextSource  $context,
  $mode = self::MODE_NORMAL 
)
static

Check if pages can be cached for this request/user.

Parameters
IContextSource$context
integer$modeOne of the HTMLFileCache::MODE_* constants (since 1.28)
Returns
bool

Definition at line 106 of file HTMLFileCache.php.

References $query, $user, as, IContextSource\getLanguage(), IContextSource\getRequest(), IContextSource\getUser(), Hooks\run(), and wfDebug().

Referenced by Article\isFileCacheable(), MediaWiki\main(), HistoryAction\onView(), and MediaWiki\run().

Member Data Documentation

const HTMLFileCache::MODE_NORMAL = 0

Definition at line 34 of file HTMLFileCache.php.

const HTMLFileCache::MODE_OUTAGE = 1

Definition at line 35 of file HTMLFileCache.php.

Referenced by MediaWiki\run().

const HTMLFileCache::MODE_REBUILD = 2

Definition at line 36 of file HTMLFileCache.php.

Referenced by RebuildFileCache\execute().


The documentation for this class was generated from the following file: