Add cache_calls metric for persistent object cache integration#219
Draft
Copilot wants to merge 10 commits into
Draft
Add cache_calls metric for persistent object cache integration#219Copilot wants to merge 10 commits into
cache_calls metric for persistent object cache integration#219Copilot wants to merge 10 commits into
Conversation
2 tasks
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
… metric Agent-Logs-Url: https://github.com/wp-cli/profile-command/sessions/d00efdc1-7144-4e26-b76c-880aeca9a768 Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
… feedback Agent-Logs-Url: https://github.com/wp-cli/profile-command/sessions/d00efdc1-7144-4e26-b76c-880aeca9a768 Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add integration for persistent object caches
Add Apr 29, 2026
redis_calls metric for persistent object cache integration
tillkruss
suggested changes
Apr 29, 2026
This comment was marked as resolved.
This comment was marked as resolved.
…ct cache backends Agent-Logs-Url: https://github.com/wp-cli/profile-command/sessions/96870b9d-2d37-4ac3-b192-b5d30a51d5fe Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
This comment was marked as resolved.
This comment was marked as resolved.
Copilot
AI
changed the title
Add
Add May 19, 2026
redis_calls metric for persistent object cache integrationcache_calls metric for persistent object cache integration
This comment was marked as resolved.
This comment was marked as resolved.
Agent-Logs-Url: https://github.com/wp-cli/profile-command/sessions/06c52567-fd1e-4fe3-a0d8-53c22f5c8e8b Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
This comment was marked as resolved.
This comment was marked as resolved.
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a new cache_calls metric to wp profile output to surface persistent object cache backend call counts across supported implementations (WP Redis, Redis Object Cache, Object Cache Pro), including end-to-end Behat coverage.
Changes:
- Add
Logger::get_object_cache_calls()helper and trackcache_callsdelta inLogger::start()/stop(). - Extend tick-based profiling to accumulate
cache_callsper function inProfiler::handle_function_tick(). - Expose
cache_callsas a selectable field forstage,hook,eval, andeval-file, and add Behat scenarios covering supported/unsupported backends.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
src/Logger.php |
Introduces cache_calls metric storage and backend-specific call counting helper. |
src/Profiler.php |
Tracks cache_calls deltas during tick-based (function-level) profiling. |
src/Command.php |
Adds cache_calls to field lists for relevant subcommands. |
features/profile-eval.feature |
Adds Behat scenarios validating cache_calls behavior with/without a persistent cache backend. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
swissspidy
reviewed
Jun 9, 2026
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.
Multiple persistent object cache plugins expose backend call counts, but
wp profilehad no way to surface this data.Changes
src/Logger.php— adds$cache_callspublic property; addsget_object_cache_calls()static helper that reads from whichever backend is active;start()captures the offset,stop()computes and stores the delta. Gracefully no-ops (shows0) when no supported backend is present.src/Profiler.php— adds$tick_cache_calls_offsetfor tick-based (function-level) profiling; mirrors the same offset/delta pattern inhandle_function_tick()via the shared helper.src/Command.php— addscache_callsto the$metricsfields forstage,hook,eval, andeval-filesubcommands.features/profile-eval.feature— two new scenarios: one assertingcache_calls = 0with the default cache; one using a minimalobject-cache.phpdrop-in that mimics thecache_callsarray format to assert the count is correct.Supported backends
The
get_object_cache_calls()helper checks each source in order:$wp_object_cache->redis_calls(array of command → count)$wp_object_cache->cache_calls(array of command → count)$wp_object_cache->metrics()->storeReads + storeWritesExample output