Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorblizzz <blizzz@arthur-schiwon.de>2022-04-22 17:51:27 +0300
committerGitHub <noreply@github.com>2022-04-22 17:51:27 +0300
commit045051271157835470104d18ed65e4a56fc4a98b (patch)
tree5dc141e34ee55995e51394f2ad7cea21f1a8ef7c
parentec3575c6468ad29af56d4b50a68823589eaeee89 (diff)
parentb2367f4567262267d1248f6bb6487ad4e52c41ce (diff)
Merge pull request #32062 from nextcloud/backport/32048/stable24
[stable24] cache storage info in memcache for 5m
-rw-r--r--lib/private/legacy/OC_Helper.php19
1 files changed, 18 insertions, 1 deletions
diff --git a/lib/private/legacy/OC_Helper.php b/lib/private/legacy/OC_Helper.php
index 547ffef8607..68fb4311ef8 100644
--- a/lib/private/legacy/OC_Helper.php
+++ b/lib/private/legacy/OC_Helper.php
@@ -44,7 +44,9 @@
*
*/
use bantu\IniGetWrapper\IniGetWrapper;
+use OC\Files\Filesystem;
use OCP\Files\Mount\IMountPoint;
+use OCP\ICacheFactory;
use OCP\IUser;
use Symfony\Component\Process\ExecutableFinder;
@@ -486,9 +488,20 @@ class OC_Helper {
* @throws \OCP\Files\NotFoundException
*/
public static function getStorageInfo($path, $rootInfo = null, $includeMountPoints = true) {
+ /** @var ICacheFactory $cacheFactory */
+ $cacheFactory = \OC::$server->get(ICacheFactory::class);
+ $memcache = $cacheFactory->createLocal('storage_info');
+
// return storage info without adding mount points
$includeExtStorage = \OC::$server->getSystemConfig()->getValue('quota_include_external_storage', false);
+ $fullPath = Filesystem::getView()->getAbsolutePath($path);
+ $cacheKey = $fullPath. '::' . ($includeMountPoints ? 'include' : 'exclude');
+ $cached = $memcache->get($cacheKey);
+ if ($cached) {
+ return $cached;
+ }
+
if (!$rootInfo) {
$rootInfo = \OC\Files\Filesystem::getFileInfo($path, $includeExtStorage ? 'ext' : false);
}
@@ -559,7 +572,7 @@ class OC_Helper {
[,,,$mountPoint] = explode('/', $mount->getMountPoint(), 4);
}
- return [
+ $info = [
'free' => $free,
'used' => $used,
'quota' => $quota,
@@ -570,6 +583,10 @@ class OC_Helper {
'mountType' => $mount->getMountType(),
'mountPoint' => trim($mountPoint, '/'),
];
+
+ $memcache->set($cacheKey, $info, 5 * 60);
+
+ return $info;
}
/**