feat: caching#93
Open
ictbeheer wants to merge 7 commits into
Open
Conversation
|
Coverage report for commit: e546243 Summary - Lines: 9.00% | Methods: 7.27%
🤖 comment via lucassabreu/comment-coverage-clover |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Pull request overview
Adds a simple read-through caching layer to the four data factories (UserData::fromUser, TermData::fromTerm, PostData::fromPost / fromCorcel, CommentData::fromComment) using WordPress's object cache API to avoid repeatedly rebuilding the same data objects within (and, with a persistent cache backend, across) requests.
Changes:
- Wraps each
from*factory with awp_cache_get/wp_cache_setpair keyed by the entity ID under per-type cache groups (yard_user_data,yard_term_data,yard_post_data,yard_comment_data). - Uses
instanceof staticto validate cached values before returning them. - No corresponding cache invalidation logic is introduced.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| src/UserData.php | Caches UserData instances by user ID under yard_user_data. |
| src/TermData.php | Caches TermData instances by term ID under yard_term_data. |
| src/PostData.php | Caches PostData instances built from both WP_Post and Corcel Post by post ID under yard_post_data. |
| src/CommentData.php | Caches CommentData instances by comment ID under yard_comment_data. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| thumbnail: get_post_thumbnail_id($post->ID) ? new ImageData(get_post_thumbnail_id($post->ID)) : null, | ||
| commentCount: post_type_supports($post->post_type, 'comments') ? (int) $post->comment_count : null, | ||
| ); | ||
| wp_cache_set($post->ID, $postData, 'yard_post_data'); |
| { | ||
| return new (self::dataClass($post->post_type))( | ||
| $cachedPostData = wp_cache_get($post->ID, 'yard_post_data', false, $found); | ||
| if ($found && $cachedPostData instanceof static) { |
| { | ||
| return new (self::dataClass($post->post_type))( | ||
| $cachedPostData = wp_cache_get($post->ID, 'yard_post_data', false, $found); | ||
| if ($found && $cachedPostData instanceof static) { |
ShunLuk
approved these changes
Jun 2, 2026
mvdhoek1
approved these changes
Jun 3, 2026
mvdhoek1
left a comment
There was a problem hiding this comment.
Goede toevoeging, heb je al een verschil kunnen merken?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.