aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--includes/filebackend/FileBackendStore.php16
1 files changed, 11 insertions, 5 deletions
diff --git a/includes/filebackend/FileBackendStore.php b/includes/filebackend/FileBackendStore.php
index 46ec17796563..6d142b982853 100644
--- a/includes/filebackend/FileBackendStore.php
+++ b/includes/filebackend/FileBackendStore.php
@@ -1581,9 +1581,10 @@ abstract class FileBackendStore extends FileBackend {
* Set the cached info for a container
*
* @param string $container Resolved container name
- * @param $val mixed Information to cache
+ * @param array $val Information to cache
+ * @return void
*/
- final protected function setContainerCache( $container, $val ) {
+ final protected function setContainerCache( $container, array $val ) {
$this->memCache->add( $this->containerCacheKey( $container ), $val, 14 * 86400 );
}
@@ -1592,6 +1593,7 @@ abstract class FileBackendStore extends FileBackend {
* The cache key is salted for a while to prevent race conditions.
*
* @param string $container Resolved container name
+ * @return void
*/
final protected function deleteContainerCache( $container ) {
if ( !$this->memCache->set( $this->containerCacheKey( $container ), 'PURGED', 300 ) ) {
@@ -1672,14 +1674,17 @@ abstract class FileBackendStore extends FileBackend {
* salting for the case when a file is created at a path were there was none before.
*
* @param string $path Storage path
- * @param $val mixed Information to cache
+ * @param array $val Stat information to cache
+ * @return void
*/
- final protected function setFileCache( $path, $val ) {
+ final protected function setFileCache( $path, array $val ) {
$path = FileBackend::normalizeStoragePath( $path );
if ( $path === null ) {
return; // invalid storage path
}
- $this->memCache->add( $this->fileCacheKey( $path ), $val, 7 * 86400 );
+ $age = time() - wfTimestamp( TS_UNIX, $val['mtime'] );
+ $ttl = min( 7 * 86400, max( 300, floor( .1 * $age ) ) );
+ $this->memCache->add( $this->fileCacheKey( $path ), $val, $ttl );
}
/**
@@ -1689,6 +1694,7 @@ abstract class FileBackendStore extends FileBackend {
* a file is created at a path were there was none before.
*
* @param string $path Storage path
+ * @return void
*/
final protected function deleteFileCache( $path ) {
$path = FileBackend::normalizeStoragePath( $path );