From e8e950a4d2972a4950e00a67cc8c1f0447701986 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Fri, 2 Sep 2016 15:41:59 +0200 Subject: more efficient querying of numeric storage ids --- lib/private/Files/Cache/Storage.php | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'lib/private/Files/Cache/Storage.php') diff --git a/lib/private/Files/Cache/Storage.php b/lib/private/Files/Cache/Storage.php index 8a076084ac5..b2bb8fd0078 100644 --- a/lib/private/Files/Cache/Storage.php +++ b/lib/private/Files/Cache/Storage.php @@ -40,9 +40,21 @@ namespace OC\Files\Cache; * @package OC\Files\Cache */ class Storage { + /** @var StorageGlobal|null */ + private static $globalCache = null; private $storageId; private $numericId; + /** + * @return StorageGlobal + */ + public static function getGlobalCache() { + if (is_null(self::$globalCache)) { + self::$globalCache = new StorageGlobal(\OC::$server->getDatabaseConnection()); + } + return self::$globalCache; + } + /** * @param \OC\Files\Storage\Storage|string $storage * @param bool $isAvailable @@ -75,12 +87,10 @@ class Storage { /** * @param string $storageId - * @return array|null + * @return array */ public static function getStorageById($storageId) { - $sql = 'SELECT * FROM `*PREFIX*storages` WHERE `id` = ?'; - $result = \OC_DB::executeAudited($sql, array($storageId)); - return $result->fetchRow(); + return self::getGlobalCache()->getStorageInfo($storageId); } /** -- cgit v1.2.3