summaryrefslogtreecommitdiff
path: root/includes/cache/FileCacheBase.php
diff options
context:
space:
mode:
Diffstat (limited to 'includes/cache/FileCacheBase.php')
-rw-r--r--includes/cache/FileCacheBase.php15
1 files changed, 12 insertions, 3 deletions
diff --git a/includes/cache/FileCacheBase.php b/includes/cache/FileCacheBase.php
index d4bf5ee6..4bf36114 100644
--- a/includes/cache/FileCacheBase.php
+++ b/includes/cache/FileCacheBase.php
@@ -51,6 +51,7 @@ abstract class FileCacheBase {
*/
final protected function baseCacheDirectory() {
global $wgFileCacheDirectory;
+
return $wgFileCacheDirectory;
}
@@ -91,6 +92,7 @@ abstract class FileCacheBase {
if ( $this->mCached === null ) {
$this->mCached = file_exists( $this->cachePath() );
}
+
return $this->mCached;
}
@@ -100,6 +102,7 @@ abstract class FileCacheBase {
*/
public function cacheTimestamp() {
$timestamp = filemtime( $this->cachePath() );
+
return ( $timestamp !== false )
? wfTimestamp( TS_MW, $timestamp )
: false;
@@ -120,7 +123,8 @@ abstract class FileCacheBase {
$cachetime = $this->cacheTimestamp();
$good = ( $timestamp <= $cachetime && $wgCacheEpoch <= $cachetime );
- wfDebug( __METHOD__ . ": cachetime $cachetime, touched '{$timestamp}' epoch {$wgCacheEpoch}, good $good\n" );
+ wfDebug( __METHOD__ .
+ ": cachetime $cachetime, touched '{$timestamp}' epoch {$wgCacheEpoch}, good $good\n" );
return $good;
}
@@ -140,6 +144,7 @@ abstract class FileCacheBase {
public function fetchText() {
if ( $this->useGzip() ) {
$fh = gzopen( $this->cachePath(), 'rb' );
+
return stream_get_contents( $fh );
} else {
return file_get_contents( $this->cachePath() );
@@ -148,7 +153,8 @@ abstract class FileCacheBase {
/**
* Save and compress text to the cache
- * @return string compressed text
+ * @param string $text
+ * @return string Compressed text
*/
public function saveText( $text ) {
global $wgUseFileCache;
@@ -165,10 +171,12 @@ abstract class FileCacheBase {
if ( !file_put_contents( $this->cachePath(), $text, LOCK_EX ) ) {
wfDebug( __METHOD__ . "() failed saving " . $this->cachePath() . "\n" );
$this->mCached = null;
+
return false;
}
$this->mCached = true;
+
return $text;
}
@@ -223,7 +231,7 @@ abstract class FileCacheBase {
/**
* Roughly increments the cache misses in the last hour by unique visitors
- * @param $request WebRequest
+ * @param WebRequest $request
* @return void
*/
public function incrMissesRecent( WebRequest $request ) {
@@ -262,6 +270,7 @@ abstract class FileCacheBase {
*/
public function getMissesRecent() {
global $wgMemc;
+
return self::MISS_FACTOR * $wgMemc->get( $this->cacheMissKey() );
}