cache OC\Files\Mount\Manager::findIn results

Signed-off-by: Robin Appelman <robin@icewind.nl>
This commit is contained in:
Robin Appelman 2018-08-16 19:02:00 +02:00
parent bb092553ef
commit 65c8fd3b29
No known key found for this signature in database
GPG Key ID: 42B69D8A64526EFB
1 changed files with 18 additions and 7 deletions

View File

@ -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,6 +57,7 @@ class Manager implements IMountManager {
$mountPoint .= '/';
}
unset($this->mounts[$mountPoint]);
$this->inPathCache->clear();
}
/**
@ -60,6 +67,7 @@ class Manager implements IMountManager {
public function moveMount($mountPoint, $target) {
$this->mounts[$target] = $this->mounts[$mountPoint];
unset($this->mounts[$mountPoint]);
$this->inPathCache->clear();
}
/**
@ -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();
}
/**