MediaWiki REL1_28
FileCacheBase Class Reference

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

Inheritance diagram for 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.
 

Public Attributes

const MISS_FACTOR = 15
 
const MISS_TTL_SEC = 3600
 

Protected Member Functions

 __construct ()
 
 baseCacheDirectory ()
 Get the base file cache directory.
 
 cacheDirectory ()
 Get the base cache directory (not specific to this file)
 
 cacheMissKey ()
 
 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

 $mCached
 
 $mExt = 'cache'
 
 $mFilePath
 
 $mKey
 
 $mType = 'object'
 
 $mUseGzip
 

Detailed Description

Base class for data storage in the file system.

Definition at line 29 of file FileCacheBase.php.

Constructor & Destructor Documentation

◆ __construct()

FileCacheBase::__construct ( )
protected

Definition at line 42 of file FileCacheBase.php.

References $wgUseGzip, and global.

Member Function Documentation

◆ baseCacheDirectory()

FileCacheBase::baseCacheDirectory ( )
finalprotected

Get the base file cache directory.

Returns
string

Definition at line 52 of file FileCacheBase.php.

References $wgFileCacheDirectory, and global.

Referenced by HTMLFileCache\cacheDirectory(), and ResourceFileCache\cacheDirectory().

◆ cacheDirectory()

FileCacheBase::cacheDirectory ( )
abstractprotected

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

Returns
string

Reimplemented in HTMLFileCache, and ResourceFileCache.

Referenced by cachePath().

◆ cacheMissKey()

FileCacheBase::cacheMissKey ( )
protected
Returns
string

Definition at line 274 of file FileCacheBase.php.

References wfMemcKey().

Referenced by getMissesRecent(), and incrMissesRecent().

◆ cachePath()

FileCacheBase::cachePath ( )
protected

Get the path to the cache file.

Returns
string

Definition at line 68 of file FileCacheBase.php.

References $dir, $mFilePath, cacheDirectory(), hashSubdirectory(), typeSubdirectory(), and useGzip().

Referenced by cacheTimestamp(), checkCacheDirs(), clearCache(), fetchText(), isCached(), HTMLFileCache\loadFromFileCache(), and saveText().

◆ cacheTimestamp()

FileCacheBase::cacheTimestamp ( )

Get the last-modified timestamp of the cache file.

Returns
string|bool TS_MW timestamp

Definition at line 103 of file FileCacheBase.php.

References $timestamp, cachePath(), TS_MW, and wfTimestamp().

Referenced by isCacheGood(), and ResourceLoader\tryRespondFromFileCache().

◆ checkCacheDirs()

FileCacheBase::checkCacheDirs ( )
protected

Create parent directors of $this->cachePath()

Returns
void

Definition at line 192 of file FileCacheBase.php.

References cachePath(), and wfMkdirParents().

Referenced by saveText().

◆ clearCache()

FileCacheBase::clearCache ( )

Clear the cache for this page.

Returns
void

Definition at line 181 of file FileCacheBase.php.

References cachePath().

◆ fetchText()

FileCacheBase::fetchText ( )

Get the uncompressed text from the cache.

Returns
string

Definition at line 144 of file FileCacheBase.php.

References cachePath(), and useGzip().

Referenced by ResourceLoader\tryRespondFromFileCache().

◆ getMissesRecent()

FileCacheBase::getMissesRecent ( )

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

Returns
int

Definition at line 265 of file FileCacheBase.php.

References $cache, and cacheMissKey().

Referenced by ResourceFileCache\isCacheWorthy().

◆ hashSubdirectory()

FileCacheBase::hashSubdirectory ( )
protected

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

Returns
string

Definition at line 212 of file FileCacheBase.php.

References $wgFileCacheDepth, and global.

Referenced by cachePath().

◆ incrMissesRecent()

FileCacheBase::incrMissesRecent ( WebRequest  $request)

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

Parameters
WebRequest$request
Returns
void

Definition at line 231 of file FileCacheBase.php.

References $cache, $request, cacheMissKey(), IP\isIPv6(), IP\isValid(), IP\sanitizeRange(), and wfMemcKey().

◆ isCached()

FileCacheBase::isCached ( )

Check if the cache file exists.

Returns
bool

Definition at line 91 of file FileCacheBase.php.

References $mCached, and cachePath().

Referenced by isCacheGood(), and ResourceFileCache\isCacheWorthy().

◆ isCacheGood()

FileCacheBase::isCacheGood (   $timestamp = '')

Check if up to date cache file exists.

Parameters
string$timestampMW_TS timestamp
Returns
bool

Definition at line 117 of file FileCacheBase.php.

References $timestamp, $wgCacheEpoch, cacheTimestamp(), global, isCached(), and wfDebug().

Referenced by ResourceLoader\tryRespondFromFileCache().

◆ saveText()

FileCacheBase::saveText (   $text)

Save and compress text to the cache.

Parameters
string$text
Returns
string Compressed text

Definition at line 159 of file FileCacheBase.php.

References cachePath(), checkCacheDirs(), useGzip(), and wfDebug().

Referenced by HTMLFileCache\saveToFileCache().

◆ typeSubdirectory()

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 203 of file FileCacheBase.php.

Referenced by cachePath().

◆ useGzip()

FileCacheBase::useGzip ( )
protected

Check if the cache is gzipped.

Returns
bool

Definition at line 136 of file FileCacheBase.php.

References $mUseGzip.

Referenced by cachePath(), fetchText(), HTMLFileCache\loadFromFileCache(), saveText(), and HTMLFileCache\saveToFileCache().

Member Data Documentation

◆ $mCached

FileCacheBase::$mCached
protected

Definition at line 36 of file FileCacheBase.php.

Referenced by isCached().

◆ $mExt

FileCacheBase::$mExt = 'cache'
protected

Definition at line 32 of file FileCacheBase.php.

◆ $mFilePath

FileCacheBase::$mFilePath
protected

Definition at line 33 of file FileCacheBase.php.

Referenced by cachePath().

◆ $mKey

FileCacheBase::$mKey
protected

Definition at line 30 of file FileCacheBase.php.

◆ $mType

FileCacheBase::$mType = 'object'
protected

Definition at line 31 of file FileCacheBase.php.

◆ $mUseGzip

FileCacheBase::$mUseGzip
protected

Definition at line 34 of file FileCacheBase.php.

Referenced by useGzip().

◆ MISS_FACTOR

const FileCacheBase::MISS_FACTOR = 15

Definition at line 39 of file FileCacheBase.php.

◆ MISS_TTL_SEC

const FileCacheBase::MISS_TTL_SEC = 3600

Definition at line 40 of file FileCacheBase.php.


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