diff options
author | Robin Appelman <robin@icewind.nl> | 2018-08-16 19:02:00 +0200 |
---|---|---|
committer | Robin Appelman <robin@icewind.nl> | 2018-08-27 16:23:01 +0200 |
commit | 65c8fd3b29e8ab9a170a411950fff467ae0776a2 (patch) | |
tree | 928900aa38b0a4b80f00851095411e12378af701 /lib | |
parent | bb092553efa3131123eab27b8631e56995986a22 (diff) | |
download | nextcloud-server-65c8fd3b29e8ab9a170a411950fff467ae0776a2.tar.gz nextcloud-server-65c8fd3b29e8ab9a170a411950fff467ae0776a2.zip |
cache OC\Files\Mount\Manager::findIn results
Signed-off-by: Robin Appelman <robin@icewind.nl>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/private/Files/Mount/Manager.php | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/lib/private/Files/Mount/Manager.php b/lib/private/Files/Mount/Manager.php index e479a7d2a86..aad75e49257 100644 --- a/lib/private/Files/Mount/Manager.php +++ b/lib/private/Files/Mount/Manager.php @@ -30,16 +30,22 @@ use OCP\Files\Mount\IMountManager; use OCP\Files\Mount\IMountPoint; class Manager implements IMountManager { - /** - * @var MountPoint[] - */ - private $mounts = array(); + /** @var MountPoint[] */ + private $mounts = []; + + /** @var CappedMemoryCache */ + private $inPathCache; + + public function __construct() { + $this->inPathCache = new CappedMemoryCache(); + } /** * @param IMountPoint $mount */ public function addMount(IMountPoint $mount) { $this->mounts[$mount->getMountPoint()] = $mount; + $this->inPathCache->clear(); } /** @@ -51,15 +57,17 @@ class Manager implements IMountManager { $mountPoint .= '/'; } unset($this->mounts[$mountPoint]); + $this->inPathCache->clear(); } /** * @param string $mountPoint * @param string $target */ - public function moveMount($mountPoint, $target){ + public function moveMount($mountPoint, $target) { $this->mounts[$target] = $this->mounts[$mountPoint]; unset($this->mounts[$mountPoint]); + $this->inPathCache->clear(); } /** @@ -73,7 +81,7 @@ class Manager implements IMountManager { $path = Filesystem::normalizePath($path); $current = $path; - while(true) { + while (true) { $mountPoint = $current . '/'; if (isset($this->mounts[$mountPoint])) { $this->pathCache[$path] = $this->mounts[$mountPoint]; @@ -108,11 +116,14 @@ class Manager implements IMountManager { $result[] = $this->mounts[$mountPoint]; } } + + $this->inPathCache[$path] = $result; return $result; } public function clear() { - $this->mounts = array(); + $this->mounts = []; + $this->inPathCache->clear(); } /** |