Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Add caching on WPOrg plugins query
  • Loading branch information
thelovekesh committed Mar 1, 2024
commit 68be6d05fd3717eebfa861e9ba9bc32cd863f8c9
8 changes: 8 additions & 0 deletions admin/plugins.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@
* @return array Array of plugin data, or empty if none/error.
*/
function perflab_query_plugin_info( string $plugin_slug ) {
$plugin = get_transient( 'perflab_plugin_info_' . $plugin_slug );

if ( $plugin ) {
return $plugin;
}

$plugin = plugins_api(
'plugin_information',
array(
Expand All @@ -37,6 +43,8 @@ function perflab_query_plugin_info( string $plugin_slug ) {
$plugin = (array) $plugin;
}

set_transient( 'perflab_plugin_info_' . $plugin_slug, $plugin, HOUR_IN_SECONDS );
Copy link
Member

Choose a reason for hiding this comment

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

The TTL could probably be higher but I don't feel strongly about it.


return $plugin;
}

Expand Down