Skip to content

Conversation

@icewind1991
Copy link
Member

Instead of either getting the local display name or searching for a calendar entry every time, cache things for 15m.
Cache is invalidated when a user changes his displayname or the calendar entry gets changed

Copy link
Member

@PVince81 PVince81 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 ok in general, nice to see that many tests

see 2 minor comments

$this->contactsManager = $contactsManager;
$this->urlGenerator = $urlGenerator;
$this->userManager = $userManager;
$this->memCache = $cacheFactory->createDistributed('cloud_id_');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure if distributed is really necessary, would local be enough and then we wouldn't need to also cache in a local array ? are we using this pattern of distributed+local array elsewhere also ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's distributed to make the cache invalidation that happen on displayname/adressbook change propagate.

The distributed+local caching is also used in the DisplayNameCache


$key = $user . '@' . ($isLocal ? 'local' : $host);
$cached = $this->cache[$key] ?? $this->memCache->get($key);
if ($cached) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if $cached is the string "0" this would not enter the if block, better always be safe with a strict check ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The cached value is an array, so "falsy" values are not a problem

Copy link
Member

@CarlSchwan CarlSchwan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to adjusts the test too ;)

Signed-off-by: Robin Appelman <[email protected]>
@PVince81 PVince81 merged commit 3ae4397 into master Sep 1, 2022
@PVince81 PVince81 deleted the cloudid-cache branch September 1, 2022 11:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3. to review Waiting for reviews

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants