MediaWiki master
MediaWiki\Cache\FileCacheBase Class Reference

Base class for data storage in the file system. More...

Inherited by HTMLFileCache.

Collaboration diagram for MediaWiki\Cache\FileCacheBase:

Public Member Functions

 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.
 

Protected Member Functions

 __construct ()
 
 baseCacheDirectory ()
 Get the base file cache directory.
 
 cacheDirectory ()
 Get the base cache directory (not specific to this file)
 
 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.
 
 typeSubdirectory ()
 Get the cache type subdirectory (with trailing slash) An extending class could use that method to alter the type -> directory mapping.
 
 useGzip ()
 Check if the cache is gzipped.
 

Protected Attributes

bool null $mCached
 lazy loaded
 
 $mExt = 'cache'
 
 $mFilePath
 
 $mKey
 
 $mType = 'object'
 
 $mUseGzip
 
ServiceOptions $options
 

Detailed Description

Base class for data storage in the file system.

Definition at line 39 of file FileCacheBase.php.

Constructor & Destructor Documentation

◆ __construct()

MediaWiki\Cache\FileCacheBase::__construct ( )
protected

Member Function Documentation

◆ baseCacheDirectory()

MediaWiki\Cache\FileCacheBase::baseCacheDirectory ( )
finalprotected

Get the base file cache directory.

Returns
string

Definition at line 75 of file FileCacheBase.php.

References MediaWiki\MainConfigNames\FileCacheDirectory.

Referenced by HTMLFileCache\cacheDirectory().

◆ cacheDirectory()

MediaWiki\Cache\FileCacheBase::cacheDirectory ( )
abstractprotected

Get the base cache directory (not specific to this file)

Returns
string

Reimplemented in HTMLFileCache.

Referenced by MediaWiki\Cache\FileCacheBase\cachePath().

◆ cacheMissKey()

MediaWiki\Cache\FileCacheBase::cacheMissKey ( BagOStuff $cache)
protected
Parameters
BagOStuff$cacheInstance that the key will be used with
Returns
string

Definition at line 291 of file FileCacheBase.php.

References Wikimedia\ObjectCache\BagOStuff\makeKey().

Referenced by MediaWiki\Cache\FileCacheBase\getMissesRecent(), and MediaWiki\Cache\FileCacheBase\incrMissesRecent().

◆ cachePath()

◆ cacheTimestamp()

MediaWiki\Cache\FileCacheBase::cacheTimestamp ( )

Get the last-modified timestamp of the cache file.

Returns
string|bool TS_MW timestamp

Definition at line 122 of file FileCacheBase.php.

References MediaWiki\Cache\FileCacheBase\cachePath(), and wfTimestamp().

Referenced by MediaWiki\Cache\FileCacheBase\isCacheGood().

◆ checkCacheDirs()

MediaWiki\Cache\FileCacheBase::checkCacheDirs ( )
protected

Create parent directors of $this->cachePath()

Returns
void

Definition at line 211 of file FileCacheBase.php.

References MediaWiki\Cache\FileCacheBase\cachePath(), and wfMkdirParents().

Referenced by MediaWiki\Cache\FileCacheBase\saveText().

◆ clearCache()

MediaWiki\Cache\FileCacheBase::clearCache ( )

Clear the cache for this page.

Returns
void

Definition at line 200 of file FileCacheBase.php.

References MediaWiki\Cache\FileCacheBase\cachePath().

◆ fetchText()

MediaWiki\Cache\FileCacheBase::fetchText ( )

Get the uncompressed text from the cache.

Returns
string

Definition at line 163 of file FileCacheBase.php.

References MediaWiki\Cache\FileCacheBase\cachePath(), and MediaWiki\Cache\FileCacheBase\useGzip().

◆ getMissesRecent()

MediaWiki\Cache\FileCacheBase::getMissesRecent ( )

Roughly gets the cache misses in the last hour by unique visitors.

Returns
int

Definition at line 280 of file FileCacheBase.php.

References MediaWiki\Cache\FileCacheBase\cacheMissKey(), and MediaWiki\MediaWikiServices\getInstance().

◆ hashSubdirectory()

MediaWiki\Cache\FileCacheBase::hashSubdirectory ( )
protected

Return relative multi-level hash subdirectory (with trailing slash) or the empty string if not $wgFileCacheDepth.

Returns
string

Definition at line 231 of file FileCacheBase.php.

References MediaWiki\MainConfigNames\FileCacheDepth.

Referenced by MediaWiki\Cache\FileCacheBase\cachePath().

◆ incrMissesRecent()

MediaWiki\Cache\FileCacheBase::incrMissesRecent ( WebRequest $request)

Roughly increments the cache misses in the last hour by unique visitors.

Parameters
WebRequest$request
Returns
void

Definition at line 250 of file FileCacheBase.php.

References MediaWiki\Cache\FileCacheBase\cacheMissKey(), MediaWiki\MediaWikiServices\getInstance(), and MediaWiki\Request\WebRequest\getIP().

◆ isCached()

MediaWiki\Cache\FileCacheBase::isCached ( )

Check if the cache file exists.

Returns
bool

Definition at line 112 of file FileCacheBase.php.

References MediaWiki\Cache\FileCacheBase\$mCached, and MediaWiki\Cache\FileCacheBase\cachePath().

Referenced by MediaWiki\Cache\FileCacheBase\isCacheGood().

◆ isCacheGood()

MediaWiki\Cache\FileCacheBase::isCacheGood ( $timestamp = '')

Check if up to date cache file exists.

Parameters
string$timestampMW_TS timestamp
Returns
bool

Definition at line 136 of file FileCacheBase.php.

References MediaWiki\MainConfigNames\CacheEpoch, MediaWiki\Cache\FileCacheBase\cacheTimestamp(), MediaWiki\Cache\FileCacheBase\isCached(), wfBoolToStr(), and wfDebug().

◆ saveText()

MediaWiki\Cache\FileCacheBase::saveText ( $text)

Save and compress text to the cache.

Parameters
string$text
Returns
string|false Compressed text

Definition at line 178 of file FileCacheBase.php.

References MediaWiki\Cache\FileCacheBase\cachePath(), MediaWiki\Cache\FileCacheBase\checkCacheDirs(), MediaWiki\Cache\FileCacheBase\useGzip(), and wfDebug().

Referenced by HTMLFileCache\saveToFileCache().

◆ typeSubdirectory()

MediaWiki\Cache\FileCacheBase::typeSubdirectory ( )
protected

Get the cache type subdirectory (with trailing slash) An extending class could use that method to alter the type -> directory mapping.

See also
HTMLFileCache::typeSubdirectory() for an example.
Returns
string

Reimplemented in HTMLFileCache.

Definition at line 222 of file FileCacheBase.php.

Referenced by MediaWiki\Cache\FileCacheBase\cachePath().

◆ useGzip()

MediaWiki\Cache\FileCacheBase::useGzip ( )
protected

Member Data Documentation

◆ $mCached

bool null MediaWiki\Cache\FileCacheBase::$mCached
protected

lazy loaded

Definition at line 55 of file FileCacheBase.php.

Referenced by MediaWiki\Cache\FileCacheBase\isCached().

◆ $mExt

MediaWiki\Cache\FileCacheBase::$mExt = 'cache'
protected

Definition at line 51 of file FileCacheBase.php.

◆ $mFilePath

MediaWiki\Cache\FileCacheBase::$mFilePath
protected

Definition at line 52 of file FileCacheBase.php.

Referenced by MediaWiki\Cache\FileCacheBase\cachePath().

◆ $mKey

MediaWiki\Cache\FileCacheBase::$mKey
protected
Initial value:
=[,,,,,]
private const CONSTRUCTOR_OPTIONS
const FileCacheDirectory
Name constant for the FileCacheDirectory setting, for use with Config::get()
const MimeType
Name constant for the MimeType setting, for use with Config::get()
const CacheEpoch
Name constant for the CacheEpoch setting, for use with Config::get()
const FileCacheDepth
Name constant for the FileCacheDepth setting, for use with Config::get()
const UseGzip
Name constant for the UseGzip setting, for use with Config::get()

Definition at line 49 of file FileCacheBase.php.

◆ $mType

MediaWiki\Cache\FileCacheBase::$mType = 'object'
protected

Definition at line 50 of file FileCacheBase.php.

◆ $mUseGzip

MediaWiki\Cache\FileCacheBase::$mUseGzip
protected

Definition at line 53 of file FileCacheBase.php.

Referenced by MediaWiki\Cache\FileCacheBase\useGzip().

◆ $options

ServiceOptions MediaWiki\Cache\FileCacheBase::$options
protected

Definition at line 57 of file FileCacheBase.php.


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