Skip to content
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

Stats: Use Transient API to Improve Cache Performance #13147

Merged
merged 1 commit into from
Jul 30, 2019

Conversation

mdawaffe
Copy link
Member

@mdawaffe mdawaffe commented Jul 30, 2019

Fixes #13121

Changes proposed in this Pull Request:

Rather than storing every cached stats item in one big option, store each separately in their own transient.

Moving to transients also means we don't need to worry about expiring the cache ourselves: Core will take care of it.

Bonus: Storing JSON serialized data is significantly more space efficient for our use case than storing data serialized by serialize(). (We're actually doing a bit of both in this PR, but still getting most of the savings.)

Is this a new feature or does it add/remove features to an existing part of Jetpack?

Bug fix.

Testing instructions:

  1. git checkout master
  2. Load the Jetpack dashboard.
  3. wp option get jetpack_restapi_stats_cache - see a bunch of stuff.
  4. git checkout fix/13121-use-transients-for-stats-cache
  5. HACK: bump JETPACK__VERSION.
  6. Load the Jetpack dashboard.
  7. wp option get jetpack_restapi_stats_cache - see that the option doesn't exist.
  8. wp transient list --search='jetpack_restapi_stats_cache_*' - see the data in the transient(s). Note the expiration.
  9. Load the Jetpack dashboard.
  10. wp transient list --search='jetpack_restapi_stats_cache_*' - see the data still in the transient(s). See that the expiration has not changed.
  11. UNHACK your JETPACK__VERSION.

Proposed changelog entry for your changes:

Improve Stats Cache performance by switching from the WordPress Options API to the WordPress Transient API.

Rather than storing every cached stats item in one big option, store each
separately in their own transient.

Moving to transients also means we don't need to worry about expiring the
cache ourselves: core will take care of it.
@mdawaffe mdawaffe added [Type] Bug When a feature is broken and / or not performing as intended [Status] Needs Review To request a review from fellow Jetpack developers. Label will be renamed soon. [Pri] High [Status] Needs Testing We need to add this change to the testing call for this month's release labels Jul 30, 2019
@mdawaffe mdawaffe added this to the 7.6 milestone Jul 30, 2019
@mdawaffe mdawaffe requested a review from a team July 30, 2019 07:07
@mdawaffe mdawaffe self-assigned this Jul 30, 2019
@jetpackbot
Copy link

Thank you for the great PR description!

When this PR is ready for review, please apply the [Status] Needs Review label. If you are an a11n, please have someone from your team review the code if possible. The Jetpack team will also review this PR and merge it to be included in the next Jetpack release.

Scheduled Jetpack release: August 6, 2019.
Scheduled code freeze: July 30, 2019

Generated by 🚫 dangerJS against 758a828

Copy link
Member

@zinigor zinigor left a comment

Choose a reason for hiding this comment

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

Works great, thank you!

@zinigor zinigor added [Status] Ready to Merge Go ahead, you can push that green button! and removed [Status] Needs Review To request a review from fellow Jetpack developers. Label will be renamed soon. labels Jul 30, 2019
Copy link
Member

@jeherve jeherve left a comment

Choose a reason for hiding this comment

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

LGTM! 👍

@jeherve jeherve merged commit 886ede4 into master Jul 30, 2019
@jeherve jeherve deleted the fix/13121-use-transients-for-stats-cache branch July 30, 2019 12:04
@matticbot matticbot added [Status] Needs Changelog and removed [Status] Ready to Merge Go ahead, you can push that green button! labels Jul 30, 2019
@jeherve jeherve added [Status] Has Changelog and removed [Status] Needs Changelog [Status] Needs Testing We need to add this change to the testing call for this month's release labels Jul 30, 2019
jeherve added a commit that referenced this pull request Jul 30, 2019
jeherve added a commit that referenced this pull request Jul 30, 2019
* Add initial changelog / testing list changes for 7.6

* Update stable tag to 7.5.3

* changelog: add #12957

* Changelog: add #12932

* Changelog: add #12867

* Changelog: add #12823

* changelog: add #12969

* changelog: add #13012

* changelog: add #12974

* Changelog: add #13059

* Changelog: add #13079

* Changelog: add #12924

* changelog: add #12954

* Changelog: add #12959

* Changelog: add #12977

* Changelog: add #12830

* Changelog: add #12926

* Changelog: add #12958

* Changelog: add #12999

* Changelog: add #13077

* Changelog: add #13083

* Changelog: add #13087

* Changelog: add #13110

* Changelog: add #13116

* Changelog: add #13117

* Changelog: add #12821

* Changelog: add #13120

* changelog: add #13139

* Changelog: add #13143

* Changelog: add #13147

* Testing list: add section about sync
jeherve added a commit that referenced this pull request Jul 30, 2019
* Add initial changelog / testing list changes for 7.6

* Update stable tag to 7.5.3

* changelog: add #12957

* Changelog: add #12932

* Changelog: add #12867

* Changelog: add #12823

* changelog: add #12969

* changelog: add #13012

* changelog: add #12974

* Changelog: add #13059

* Changelog: add #13079

* Changelog: add #12924

* changelog: add #12954

* Changelog: add #12959

* Changelog: add #12977

* Changelog: add #12830

* Changelog: add #12926

* Changelog: add #12958

* Changelog: add #12999

* Changelog: add #13077

* Changelog: add #13083

* Changelog: add #13087

* Changelog: add #13110

* Changelog: add #13116

* Changelog: add #13117

* Changelog: add #12821

* Changelog: add #13120

* changelog: add #13139

* Changelog: add #13143

* Changelog: add #13147

* Testing list: add section about sync
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Pri] High [Type] Bug When a feature is broken and / or not performing as intended
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Stats: store stats in transient instead of Jetpack option
5 participants