In the onSkinTemplateNavigation__Universal in ReadingLists HookHandler, there are various database queries run on page views for users with ReadingLists enabled (e.g. to get the default reading list url for a user and number of items in the reading list)
onSkinTemplateNavigation__Universal:
- getDefaultReadingListUrl - this should very rarely change and should be cached per-user
- setupForUser - gets list metadata
- gets the reading list size (from rl_size column) to pass to frontend for metrics collection (in the reading list experiment)
- reading list id
We should invalidate the relevant caches when a page is added or removed from the reading list (for the reading list size cache or metadata)
In the ReadingListRepository, we could consider using WANObjectCache::getWithSetCallback()
reading list contents:
- getListsByPage()
- gets whether a page is in the user's default reading list (whether to show the bookmarkOutline or bookmark icon - save or unsave the page)
- gets the reading list entry id (for the JS api call to save/unsave)
possibly cache per user:
cache key: readinglists:user_bookmarks:{userId}:{readingListId}
$bookmarkedPages = $cache->getWithSetCallback($cacheKey, 3600, function() use ($repository) {
return $repository->getUserBookmarkMap($userId);
});getUserBookmarkMap would be a method in the repository that builds a map (array) with page id -> reading list entry id
$bookmarks[$row->rle_title] = (int)$row->rle_id;