69 if ( $this->mFilePath !==
null ) {
74 # Build directories (methods include the trailing "/")
76 # Avoid extension confusion
77 $key = str_replace(
'.',
'%2E', urlencode( $this->mKey ) );
78 # Build the full file path
79 $this->mFilePath =
"{$dir}/{$subDirs}{$key}.{$this->mExt}";
81 $this->mFilePath .=
'.gz';
92 if ( $this->mCached ===
null ) {
93 $this->mCached = file_exists( $this->
cachePath() );
104 $timestamp = filemtime( $this->
cachePath() );
106 return ( $timestamp !==
false )
125 $good = ( $timestamp <= $cachetime &&
$wgCacheEpoch <= $cachetime );
127 ": cachetime $cachetime, touched '{$timestamp}' epoch {$wgCacheEpoch}, good $good\n" );
146 $fh = gzopen( $this->
cachePath(),
'rb' );
148 return stream_get_contents( $fh );
150 return file_get_contents( $this->
cachePath() );
161 $text = gzencode( $text );
165 if ( !file_put_contents( $this->
cachePath(), $text, LOCK_EX ) ) {
167 $this->mCached =
null;
172 $this->mCached =
true;
182 MediaWiki\suppressWarnings();
184 MediaWiki\restoreWarnings();
185 $this->mCached =
false;
204 return $this->mType .
'/';
217 $hash = md5( $this->mKey );
219 $subdir .= substr( $hash, 0, $i ) .
'/';
232 if ( mt_rand( 0, self::MISS_FACTOR - 1 ) == 0 ) {
233 $cache = ObjectCache::getLocalClusterInstance();
234 # Get a large IP range that should include the user even if that
235 # person's IP address changes
237 if ( !IP::isValid( $ip ) ) {
240 $ip = IP::isIPv6( $ip )
241 ? IP::sanitizeRange(
"$ip/32" )
242 : IP::sanitizeRange(
"$ip/16" );
244 # Bail out if a request already came from this range...
245 $key =
$cache->makeKey( static::class,
'attempt', $this->mType, $this->mKey, $ip );
246 if (
$cache->get( $key ) ) {
249 $cache->set( $key, 1, self::MISS_TTL_SEC );
251 # Increment the number of cache misses...
253 if (
$cache->get( $key ) ===
false ) {
254 $cache->set( $key, 1, self::MISS_TTL_SEC );
266 $cache = ObjectCache::getLocalClusterInstance();
276 return $cache->makeKey( static::class,
'misses', $this->mType, $this->mKey );
$wgCacheEpoch
Set this to current time to invalidate all prior cached pages.
$wgFileCacheDepth
Depth of the subdirectory hierarchy to be created under $wgFileCacheDirectory.
$wgUseGzip
When using the file cache, we can store the cached HTML gzipped to save disk space.
$wgFileCacheDirectory
Directory where the cached page will be saved.
wfDebug( $text, $dest='all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
wfMkdirParents( $dir, $mode=null, $caller=null)
Make directory, and make all parent directories if they don't exist.
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
interface is intended to be more or less compatible with the PHP memcached client.
Base class for data storage in the file system.
isCacheGood( $timestamp='')
Check if up to date cache file exists.
useGzip()
Check if the cache is gzipped.
cachePath()
Get the path to the cache file.
saveText( $text)
Save and compress text to the cache.
fetchText()
Get the uncompressed text from the cache.
hashSubdirectory()
Return relative multi-level hash subdirectory (with trailing slash) or the empty string if not $wgFil...
getMissesRecent()
Roughly gets the cache misses in the last hour by unique visitors.
cacheDirectory()
Get the base cache directory (not specific to this file)
checkCacheDirs()
Create parent directors of $this->cachePath()
cacheTimestamp()
Get the last-modified timestamp of the cache file.
clearCache()
Clear the cache for this page.
typeSubdirectory()
Get the cache type subdirectory (with trailing slash) An extending class could use that method to alt...
cacheMissKey(BagOStuff $cache)
baseCacheDirectory()
Get the base file cache directory.
incrMissesRecent(WebRequest $request)
Roughly increments the cache misses in the last hour by unique visitors.
isCached()
Check if the cache file exists.
The WebRequest class encapsulates getting at data passed in the URL or via a POSTed form stripping il...
do that in ParserLimitReportFormat instead use this to modify the parameters of the image all existing parser cache entries will be invalid To avoid you ll need to handle that somehow(e.g. with the RejectParserCacheValue hook) because MediaWiki won 't do it for you. & $defaults also a ContextSource after deleting those rows but within the same transaction you ll probably need to make sure the header is varied on $request