Skip to content

Commit

Permalink
Stats: Always refresh cache on success (#39955)
Browse files Browse the repository at this point in the history
* always cache successful response

* changelog

* Update projects/packages/stats-admin/changelog/fix-always-replace-cache-value-on-success

* fix changelog

* changelog

Committed via a GitHub action: https://github.com/Automattic/jetpack/actions/runs/11585297554

Upstream-Ref: Automattic/jetpack@49eddfe
  • Loading branch information
kangzj authored and matticbot committed Oct 30, 2024
1 parent dd326b5 commit f7fd353
Show file tree
Hide file tree
Showing 7 changed files with 98 additions and 93 deletions.
60 changes: 30 additions & 30 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion vendor/automattic/jetpack-mu-wpcom/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"automattic/jetpack-connection": "^5.1.5",
"automattic/jetpack-masterbar": "^0.9.7",
"automattic/jetpack-redirect": "^2.0.4",
"automattic/jetpack-stats-admin": "^0.22.4",
"automattic/jetpack-stats-admin": "^0.22.5-alpha",
"automattic/jetpack-status": "^4.0.2",
"automattic/scheduled-updates": "^0.13.5",
"automattic/jetpack-compat": "^3.0.2",
Expand Down
7 changes: 7 additions & 0 deletions vendor/automattic/jetpack-stats-admin/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## 0.22.5-alpha - unreleased

This is an alpha version! The changes listed here are not final.

### Fixed
- API cache not refreshing when cache is bypassed

## 0.22.4 - 2024-10-28
### Changed
- Odyssey Stats cache busting: Use option instead of transient. [#39887]
Expand Down
2 changes: 1 addition & 1 deletion vendor/automattic/jetpack-stats-admin/src/class-main.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class Main {
/**
* Stats version.
*/
const VERSION = '0.22.4';
const VERSION = '0.22.5-alpha';

/**
* Singleton Main instance.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,8 @@ public static function request_as_blog_cached( $path, $version = '1.1', $args =
return $response_body;
}

if ( $use_cache ) {
// Cache the successful JSON response for 5 minutes.
set_transient( $cache_key, wp_json_encode( $response_body ), 5 * MINUTE_IN_SECONDS );
}
// Cache the response for 5 minutes.
set_transient( $cache_key, wp_json_encode( $response_body ), 5 * MINUTE_IN_SECONDS );

return $response_body;
}
Expand Down
Loading

0 comments on commit f7fd353

Please sign in to comment.