mirror of
https://github.com/nextcloud/server.git
synced 2026-02-20 00:12:30 -05:00
Merge pull request #54438 from nextcloud/perf/caldav/cache-empty-shares-when-preloading
perf(caldav): also cache empty share arrays
This commit is contained in:
commit
eb34ddbf97
1 changed files with 19 additions and 1 deletions
|
|
@ -131,8 +131,9 @@ abstract class Backend {
|
|||
* @return list<array{href: string, commonName: string, status: int, readOnly: bool, '{http://owncloud.org/ns}principal': string, '{http://owncloud.org/ns}group-share': bool}>
|
||||
*/
|
||||
public function getShares(int $resourceId): array {
|
||||
/** @var list<array{href: string, commonName: string, status: int, readOnly: bool, '{http://owncloud.org/ns}principal': string, '{http://owncloud.org/ns}group-share': bool}>|null $cached */
|
||||
$cached = $this->shareCache->get((string)$resourceId);
|
||||
if ($cached) {
|
||||
if (is_array($cached)) {
|
||||
return $cached;
|
||||
}
|
||||
|
||||
|
|
@ -176,6 +177,23 @@ abstract class Backend {
|
|||
];
|
||||
$this->shareCache->set((string)$resourceId, $sharesByResource[$resourceId]);
|
||||
}
|
||||
|
||||
// Also remember resources with no shares to prevent superfluous (empty) queries later on
|
||||
foreach ($resourceIds as $resourceId) {
|
||||
$hasShares = false;
|
||||
foreach ($rows as $row) {
|
||||
if ((int)$row['resourceid'] === $resourceId) {
|
||||
$hasShares = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ($hasShares) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$this->shareCache->set((string)$resourceId, []);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in a new issue