Browse Source
Merge pull request #38591 from nextcloud/fix/caching/avoid-haskey-get
fix(caching): Avoid checking existence before fetching
pull/38777/head
Simon L
3 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with
12 additions and
8 deletions
-
apps/files_external/lib/Lib/Storage/Swift.php
-
apps/files_sharing/lib/External/Storage.php
-
apps/files_sharing/lib/SharedMount.php
-
lib/private/Accounts/AccountManager.php
|
|
|
@ -126,9 +126,10 @@ class Swift extends \OC\Files\Storage\Common { |
|
|
|
* @throws \OCP\Files\StorageNotAvailableException |
|
|
|
*/ |
|
|
|
private function fetchObject(string $path) { |
|
|
|
if ($this->objectCache->hasKey($path)) { |
|
|
|
$cached = $this->objectCache->get($path); |
|
|
|
if ($cached !== null) { |
|
|
|
// might be "false" if object did not exist from last check
|
|
|
|
return $this->objectCache->get($path); |
|
|
|
return $cached; |
|
|
|
} |
|
|
|
try { |
|
|
|
$object = $this->getContainer()->getObject($path); |
|
|
|
|
|
|
|
@ -265,8 +265,9 @@ class Storage extends DAV implements ISharedStorage, IDisableEncryptionStorage, |
|
|
|
|
|
|
|
private function testRemoteUrl(string $url): bool { |
|
|
|
$cache = $this->memcacheFactory->createDistributed('files_sharing_remote_url'); |
|
|
|
if ($cache->hasKey($url)) { |
|
|
|
return (bool)$cache->get($url); |
|
|
|
$cached = $cache->get($url); |
|
|
|
if ($cached !== null) { |
|
|
|
return (bool)$cached; |
|
|
|
} |
|
|
|
|
|
|
|
$client = $this->httpClient->newClient(); |
|
|
|
|
|
|
|
@ -117,8 +117,9 @@ class SharedMount extends MountPoint implements MoveableMount { |
|
|
|
$this->eventDispatcher->dispatchTyped($event); |
|
|
|
$parent = $event->getParent(); |
|
|
|
|
|
|
|
if ($folderExistCache->hasKey($parent)) { |
|
|
|
$parentExists = $folderExistCache->get($parent); |
|
|
|
$cached = $folderExistCache->get($parent); |
|
|
|
if ($cached) { |
|
|
|
$parentExists = $cached; |
|
|
|
} else { |
|
|
|
$parentExists = $this->recipientView->is_dir($parent); |
|
|
|
$folderExistCache->set($parent, $parentExists); |
|
|
|
|
|
|
|
@ -795,8 +795,9 @@ class AccountManager implements IAccountManager { |
|
|
|
} |
|
|
|
|
|
|
|
public function getAccount(IUser $user): IAccount { |
|
|
|
if ($this->internalCache->hasKey($user->getUID())) { |
|
|
|
return $this->internalCache->get($user->getUID()); |
|
|
|
$cached = $this->internalCache->get($user->getUID()); |
|
|
|
if ($cached !== null) { |
|
|
|
return $cached; |
|
|
|
} |
|
|
|
$account = $this->parseAccountData($user, $this->getUser($user)); |
|
|
|
$this->internalCache->set($user->getUID(), $account); |
|
|
|
|