-
Notifications
You must be signed in to change notification settings - Fork 275
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reduce duplicate queries when fetching user boards an permissions #3161
Conversation
af1e0b8
to
5a566c0
Compare
5a566c0
to
cb716ee
Compare
lib/Db/BoardMapper.php
Outdated
$groupBoards = $this->findAllByGroups($userId, $groups,null, null, $since, $includeArchived); | ||
$circleBoards = $this->findAllByCircles($userId, null, null, $since, $includeArchived); | ||
return array_unique(array_merge($userBoards, $groupBoards, $circleBoards)); | ||
if (!array_key_exists($userId, $this->userBoardCache)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isset()
is said to be faster, but there is a small difference –https://www.php.net/manual/en/function.array-key-exists.php example #2. For consideration.
lib/Db/BoardMapper.php
Outdated
@@ -39,6 +39,8 @@ class BoardMapper extends DeckMapper implements IPermissionMapper { | |||
|
|||
private $circlesEnabled; | |||
|
|||
private $userBoardCache = []; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could be also CappedMemoryCache to avoid overflow.
lib/Service/PermissionService.php
Outdated
return $board && $userId === $board->getOwner(); | ||
} catch (DoesNotExistException | MultipleObjectsReturnedException $e) { | ||
} | ||
return false; | ||
} | ||
|
||
private function getBoard($boardId): Board { | ||
if (!array_key_exists($boardId, $this->boardCache)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also isset for consideration
80d2580
to
b4cee7f
Compare
/backport to stable22 |
/backport to stable1.4 |
Looking into the tests |
Signed-off-by: Julius Härtl <jus@bitgrid.net>
b4cee7f
to
ae2aa8c
Compare
First step to reduce the amounts of queries that happened during collecting incoming shares when setting up the filesystem for users.
Already gives quite some improvement in test setup with 1 shared board having 3 cards with a handful of attachments on each:
https://blackfire.io/profiles/compare/67ec272e-9530-491b-afb2-0fb2c9b06f59/graph