question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Invalidate cached ideas on server on idea activity

See original GitHub issue

Feature Description

As mentioned on https://github.com/google/site-kit-wp/issues/3852, the logic for displaying a notice based on new or saved ideas can be based on stale cached ideas in transients. These are currently cached for 1 day and never manually invalidated, which can easily lead to the wrong notice shown or even a notice to show when none should be shown.


Do not alter or remove anything below. The following sections will be managed by moderators only.

Acceptance criteria

  • Transients for new and saved ideas should live no longer on the server side than on the client – their expiration times should be set to 1 hour
  • Transients for new and saved ideas should be invalidated whenever actions are taken that would change the number of new or saved ideas (such as pinning, unpinning, or changes to post status)

Implementation Brief

In includes/Modules/Idea_Hub.php:

  • Everywhere (in includes/Modules/Idea_Hub.php) that we set our transients for DAY_IN_SECONDS, change it to HOUR_IN_SECONDS.

https://github.com/google/site-kit-wp/blob/63fc48c365cd98fad1d0706d0c7835d03696565a/includes/Modules/Idea_Hub.php#L306 https://github.com/google/site-kit-wp/blob/63fc48c365cd98fad1d0706d0c7835d03696565a/includes/Modules/Idea_Hub.php#L343 https://github.com/google/site-kit-wp/blob/63fc48c365cd98fad1d0706d0c7835d03696565a/includes/Modules/Idea_Hub.php#L356

We delete transients with $this->transients->delete()

Idea pinning and deleting is via the endpoint update-idea-state, so we update it to delete the two transients TRANSIENT_SAVED_IDEAS and TRANSIENT_NEW_IDEAS prior to the return statement in the parse_data_response function: https://github.com/google/site-kit-wp/blob/63fc48c365cd98fad1d0706d0c7835d03696565a/includes/Modules/Idea_Hub.php#L635

Idea creation is via the endpoint create-idea-draft-post, so we update it to delete the two transients TRANSIENT_SAVED_IDEAS and TRANSIENT_NEW_IDEAS prior to the return statement: https://github.com/google/site-kit-wp/blob/63fc48c365cd98fad1d0706d0c7835d03696565a/includes/Modules/Idea_Hub.php#L513

Test Coverage

  • N/A

Visual Regression Changes

QA Brief

Changelog entry

  • Update the Idea_Hub class to invalidate cached ideas when an idea is modified or a new post is created.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
ivankruchkoffcommented, Aug 23, 2021

@aaemnnosttv but that’s already covered in the IB by the create-idea-draft-post endpoint update.

0reactions
wpdarrencommented, Aug 31, 2021

QA Update: ✅

Verified:

  • If there are ideas that are saved, the notification is Want some inspiration for a new post? Revisit your saved ideas in Site Kit
  • If there are no idea saved, the notification is Want some inspiration for a new post? Review your new ideas in Site Kit
Read more comments on GitHub >

github_iconTop Results From Across the Web

Invalidate caches | IntelliJ IDEA Documentation - JetBrains
When you invalidate the cache, IntelliJ IDEA removes the cache files for all projects ever run in the current version of the IDE....
Read more >
How to clean project cache in IntelliJ IDEA like Eclipse's clean?
From the main menu, select File | Invalidate Caches. In the Invalidate Caches dialog, Click Invalidate and Restart . If you click Just...
Read more >
Caching - Gotchas & Lessons Learned - Manish Pandit's Blog
This is the case when the cached data is highly mutable, and gets invalidated way too often to be of any value for...
Read more >
Option to clear cache for a specific project or a dashboard on ...
It's been 6 months we started using Tableau Server. ... to give a command kind of utility which can clear cache for an...
Read more >
Clear Input Data Cache - Alteryx Community
Alteryx Designer Ideas. Share your Designer product ideas - we're listening! Submitting an Idea? Be sure to review our Idea ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found