MediaWiki master
HTMLFileCache Class Reference

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

Inherits MediaWiki\Cache\FileCacheBase.

Collaboration diagram for HTMLFileCache:

Public Member Functions

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

Static Public Member Functions

static clearFileCache ( $page)
 Clear the file caches for a page for all actions.
 
static useFileCache (IContextSource $context, $mode=self::MODE_NORMAL)
 Check if pages can be cached for this request/user.
 

Public Attributes

const MODE_NORMAL = 0
 
const MODE_OUTAGE = 1
 
const MODE_REBUILD = 2
 

Protected Member Functions

 cacheDirectory ()
 Get the base file cache directory.
 
 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.
 
- Protected Member Functions inherited from MediaWiki\Cache\FileCacheBase
 __construct ()
 
 baseCacheDirectory ()
 Get the base file cache directory.
 
 cacheMissKey (BagOStuff $cache)
 
 cachePath ()
 Get the path to the cache file.
 
 checkCacheDirs ()
 Create parent directors of $this->cachePath()
 
 hashSubdirectory ()
 Return relative multi-level hash subdirectory (with trailing slash) or the empty string if not $wgFileCacheDepth.
 
 useGzip ()
 Check if the cache is gzipped.
 

Additional Inherited Members

- Protected Attributes inherited from MediaWiki\Cache\FileCacheBase
bool null $mCached
 lazy loaded
 
string $mExt = 'cache'
 
string null $mFilePath
 
string $mKey
 
string $mType = 'object'
 
bool $mUseGzip
 
ServiceOptions $options
 

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 39 of file HTMLFileCache.php.

Constructor & Destructor Documentation

◆ __construct()

HTMLFileCache::__construct ( $page,
$action )
Parameters
PageIdentity | string$pagePageIdentity object or prefixed DB key string
string$action

Definition at line 53 of file HTMLFileCache.php.

Member Function Documentation

◆ cacheDirectory()

HTMLFileCache::cacheDirectory ( )
protected

Get the base file cache directory.

Returns
string

Reimplemented from MediaWiki\Cache\FileCacheBase.

Definition at line 69 of file HTMLFileCache.php.

References MediaWiki\Cache\FileCacheBase\baseCacheDirectory().

◆ clearFileCache()

static HTMLFileCache::clearFileCache ( $page)
static

Clear the file caches for a page for all actions.

Parameters
PageIdentity | string$pagePageIdentity object or prefixed DB key string
Returns
bool Whether $wgUseFileCache is enabled

Definition at line 227 of file HTMLFileCache.php.

◆ loadFromFileCache()

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

Read from cache to context output.

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

Definition at line 146 of file HTMLFileCache.php.

References MediaWiki\Cache\FileCacheBase\cachePath(), MediaWiki\Context\IContextSource\getOutput(), MediaWiki\Context\IContextSource\getTitle(), MediaWiki\Cache\FileCacheBase\useGzip(), wfClientAcceptsGzip(), and wfDebug().

◆ saveToFileCache()

HTMLFileCache::saveToFileCache ( $text)

Save this cache object with the given text.

Use this as an ob_start() handler.

Normally this is only registered 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 process.

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

Definition at line 187 of file HTMLFileCache.php.

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

◆ typeSubdirectory()

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

Reimplemented from MediaWiki\Cache\FileCacheBase.

Definition at line 79 of file HTMLFileCache.php.

◆ useFileCache()

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

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

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

Definition at line 93 of file HTMLFileCache.php.

References MediaWiki\Context\IContextSource\getLanguage(), MediaWiki\Context\IContextSource\getRequest(), and MediaWiki\Context\IContextSource\getUser().

Member Data Documentation

◆ MODE_NORMAL

const HTMLFileCache::MODE_NORMAL = 0

Definition at line 40 of file HTMLFileCache.php.

◆ MODE_OUTAGE

const HTMLFileCache::MODE_OUTAGE = 1

Definition at line 41 of file HTMLFileCache.php.

◆ MODE_REBUILD

const HTMLFileCache::MODE_REBUILD = 2

Definition at line 42 of file HTMLFileCache.php.


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