Merge pull request #23713 from woocommerce/fix/webhooks-object-caching
Use WC_Cache_Helper::get_cache_prefix for webhook count cache
This commit is contained in:
commit
2cfc7b64c1
|
@ -370,13 +370,13 @@ class WC_Webhook_Data_Store implements WC_Webhook_Data_Store_Interface {
|
|||
*/
|
||||
protected function get_webhook_count( $status = 'active' ) {
|
||||
global $wpdb;
|
||||
|
||||
$count = wp_cache_get( $status . '_count', 'webhooks' );
|
||||
$cache_key = WC_Cache_Helper::get_cache_prefix( 'webhooks' ) . $status . '_count';
|
||||
$count = wp_cache_get( $cache_key, 'webhooks' );
|
||||
|
||||
if ( false === $count ) {
|
||||
$count = absint( $wpdb->get_var( $wpdb->prepare( "SELECT count( webhook_id ) FROM {$wpdb->prefix}wc_webhooks WHERE `status` = %s;", $status ) ) );
|
||||
|
||||
wp_cache_add( $status . '_count', $count, 'webhooks' );
|
||||
wp_cache_add( $cache_key, $count, 'webhooks' );
|
||||
}
|
||||
|
||||
return $count;
|
||||
|
|
Loading…
Reference in New Issue