summaryrefslogtreecommitdiffstats
path: root/lib/private/Files/Mount
diff options
context:
space:
mode:
authorRobin Appelman <robin@icewind.nl>2018-08-16 19:02:00 +0200
committerRobin Appelman <robin@icewind.nl>2018-08-16 19:02:00 +0200
commitf7ae235372ee5647003c407dff7eca83cb7a1322 (patch)
tree29711f0793c86eae72f0b8df10610b949d4406ce /lib/private/Files/Mount
parentf8116ad4cf5bf806417b3668dea885c672293109 (diff)
downloadnextcloud-server-f7ae235372ee5647003c407dff7eca83cb7a1322.tar.gz
nextcloud-server-f7ae235372ee5647003c407dff7eca83cb7a1322.zip
cache OC\Files\Mount\Manager::findIn results
Signed-off-by: Robin Appelman <robin@icewind.nl>
Diffstat (limited to 'lib/private/Files/Mount')
-rw-r--r--lib/private/Files/Mount/Manager.php19
1 files changed, 17 insertions, 2 deletions
diff --git a/lib/private/Files/Mount/Manager.php b/lib/private/Files/Mount/Manager.php
index b86142b4d51..1293b8549a5 100644
--- a/lib/private/Files/Mount/Manager.php
+++ b/lib/private/Files/Mount/Manager.php
@@ -38,8 +38,12 @@ class Manager implements IMountManager {
/** @var CappedMemoryCache */
private $pathCache;
+ /** @var CappedMemoryCache */
+ private $inPathCache;
+
public function __construct() {
$this->pathCache = new CappedMemoryCache();
+ $this->inPathCache = new CappedMemoryCache();
}
/**
@@ -48,6 +52,7 @@ class Manager implements IMountManager {
public function addMount(IMountPoint $mount) {
$this->mounts[$mount->getMountPoint()] = $mount;
$this->pathCache->clear();
+ $this->inPathCache->clear();
}
/**
@@ -60,16 +65,18 @@ class Manager implements IMountManager {
}
unset($this->mounts[$mountPoint]);
$this->pathCache->clear();
+ $this->inPathCache->clear();
}
/**
* @param string $mountPoint
* @param string $target
*/
- public function moveMount(string $mountPoint, string $target){
+ public function moveMount(string $mountPoint, string $target) {
$this->mounts[$target] = $this->mounts[$mountPoint];
unset($this->mounts[$mountPoint]);
$this->pathCache->clear();
+ $this->inPathCache->clear();
}
/**
@@ -87,7 +94,7 @@ class Manager implements IMountManager {
}
$current = $path;
- while(true) {
+ while (true) {
$mountPoint = $current . '/';
if (isset($this->mounts[$mountPoint])) {
$this->pathCache[$path] = $this->mounts[$mountPoint];
@@ -114,6 +121,11 @@ class Manager implements IMountManager {
public function findIn(string $path): array {
\OC_Util::setupFS();
$path = $this->formatPath($path);
+
+ if (isset($this->inPathCache[$path])) {
+ return $this->inPathCache[$path];
+ }
+
$result = [];
$pathLength = \strlen($path);
$mountPoints = array_keys($this->mounts);
@@ -122,12 +134,15 @@ class Manager implements IMountManager {
$result[] = $this->mounts[$mountPoint];
}
}
+
+ $this->inPathCache[$path] = $result;
return $result;
}
public function clear() {
$this->mounts = [];
$this->pathCache->clear();
+ $this->inPathCache->clear();
}
/**