aboutsummaryrefslogtreecommitdiffstats
path: root/includes/filebackend/FileBackendStore.php
diff options
context:
space:
mode:
authorAaron Schulz <aschulz@wikimedia.org>2013-04-14 13:32:34 -0700
committerGerrit Code Review <gerrit@wikimedia.org>2013-04-19 03:32:57 +0000
commit79910f36d47270e802e9ff3a36b4f10b5f1fa686 (patch)
tree7e48814317ee94a8404b9b495476e426d7534048 /includes/filebackend/FileBackendStore.php
parent14fc5f5a937bda3b1cb3ba6a450359d723440283 (diff)
downloadmediawikicore-79910f36d47270e802e9ff3a36b4f10b5f1fa686.tar.gz
mediawikicore-79910f36d47270e802e9ff3a36b4f10b5f1fa686.zip
[FileBackend] Made stat cache factor in last-modified time.
* This should lesson the chance of consistency problems if there is any memcached flapping. * Also cleaned up some documentation. Change-Id: I89401892c7e848fcff0b093eaa861dfe02387a5c
Diffstat (limited to 'includes/filebackend/FileBackendStore.php')
-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 );