You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
should use the Cache API to avoid hundreds of duplicate queries (in our case 350 for a mid-complex category page, using 30 theme options and 4 meta keys)
I've tried this for theme options and got no more duplicates:
// build a safe cache key and group from class name, field name and storage key comparisons
$cache_key = 'crb_' . md5( get_class( $this ) . $field->get_name() . $storage_key_comparisons );
$cache_group = 'crb_datastore';
// Try to get the cached result
$storage_array = wp_cache_get( $cache_key, $cache_group );
if ( $storage_array === false ) {
// If cache is empty, perform the query
$storage_array = $wpdb->get_results( '
SELECT `option_name` AS `key`, `option_value` AS `value`
FROM ' . $wpdb->options . '
WHERE ' . $storage_key_comparisons . '
ORDER BY `option_name` ASC
' );
// Store the result in cache
wp_cache_set( $cache_key, $storage_array, $cache_group, 3600 ); // Cache TTL should be configurable
}
The text was updated successfully, but these errors were encountered:
The SELECTs in
core/Datastore/Theme_Options_Datastore.php
core/Datastore/Meta_Datastore.php
should use the Cache API to avoid hundreds of duplicate queries (in our case 350 for a mid-complex category page, using 30 theme options and 4 meta keys)
I've tried this for theme options and got no more duplicates:
The text was updated successfully, but these errors were encountered: