diff options
author | Morris Jobke <hey@morrisjobke.de> | 2016-09-08 21:09:14 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-09-08 21:09:14 +0200 |
commit | 5ac26d12f0a771bcaf8a44acdb469b68daebc446 (patch) | |
tree | 0393b11ecdfa483f287f6137a119bd67c32e6783 /lib/private/Files/Cache/Storage.php | |
parent | e18fecae472ef9a9da0be724849285891d855b67 (diff) | |
parent | e8e950a4d2972a4950e00a67cc8c1f0447701986 (diff) | |
download | nextcloud-server-5ac26d12f0a771bcaf8a44acdb469b68daebc446.tar.gz nextcloud-server-5ac26d12f0a771bcaf8a44acdb469b68daebc446.zip |
Merge pull request #1247 from nextcloud/storage-id-global-cache
more efficient querying of numeric storage ids
Diffstat (limited to 'lib/private/Files/Cache/Storage.php')
-rw-r--r-- | lib/private/Files/Cache/Storage.php | 18 |
1 files changed, 14 insertions, 4 deletions
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,10 +40,22 @@ 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 * @throws \RuntimeException @@ -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); } /** |