From: Aaron Schulz Date: Sun, 19 May 2013 20:15:50 +0000 (-0700) Subject: Made SwiftFileBackend::loadObjectListing() populate stat entries in reverse order. X-Git-Tag: 1.31.0-rc.0~19471^2 X-Git-Url: http://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/exercices/?a=commitdiff_plain;h=01b564403e4f12978ad1f941b680633a4eb77952;p=lhc%2Fweb%2Fwiklou.git Made SwiftFileBackend::loadObjectListing() populate stat entries in reverse order. Change-Id: I07bf9c852729d65cee72364ca3249e31936d0562 --- diff --git a/includes/filebackend/SwiftFileBackend.php b/includes/filebackend/SwiftFileBackend.php index f9e2ce47d9..54a90d32f5 100644 --- a/includes/filebackend/SwiftFileBackend.php +++ b/includes/filebackend/SwiftFileBackend.php @@ -1111,7 +1111,11 @@ class SwiftFileBackend extends FileBackendStore { $names = array(); $storageDir = rtrim( $params['dir'], '/' ); $suffixStart = ( $dir === '' ) ? 0 : strlen( $dir ) + 1; // size of "path/to/dir/" - foreach ( $cfObjects as $object ) { + // Iterate over the list *backwards* as this primes the stat cache, which is LRU. + // If this fills the cache and the caller stats an uncached file before stating + // the ones on the listing, there would be zero cache hits if this went forwards. + for ( end( $cfObjects ); key( $cfObjects ) !== null; prev( $cfObjects ) ) { + $object = current( $cfObjects ); $path = "{$storageDir}/" . substr( $object->name, $suffixStart ); $val = array( // Convert dates like "Tue, 03 Jan 2012 22:01:04 GMT" to TS_MW @@ -1122,7 +1126,7 @@ class SwiftFileBackend extends FileBackendStore { $this->cheapCache->set( $path, 'stat', $val ); $names[] = $object->name; } - return $names; + return array_reverse( $names ); // keep the paths in original order } /**