[wp-trac] [WordPress Trac] #57625: WP_Query cache memory leak
WordPress Trac
noreply at wordpress.org
Mon Feb 6 23:26:42 UTC 2023
#57625: WP_Query cache memory leak
--------------------------+------------------------------
Reporter: owi | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Cache API | Version:
Severity: normal | Resolution:
Keywords: | Focuses: performance
--------------------------+------------------------------
Comment (by peterwilsoncc):
@owi I'm considering whether an action can be created to allow persistent
caches to detect when the last changed value has been updated.
Something like this but it would also need to consider the creation of
values in `wp_cache_get_last_changed()`.
{{{#!php
<?php
/**
* Sets the last changed time for the 'posts' cache group.
*
* @since 5.0.0
*/
function wp_cache_set_posts_last_changed() {
/*
* This value is obtained via the cache key directly to avoid the
* generation of a new key by `wp_cache_get_last_changed()`. This
* allows the action to indicate whether the value was set prior
* to this function call.
*/
$previous_value = wp_cache_get( 'last_changed', 'posts' );
$value = microtime();
wp_cache_set( 'last_changed', $value, 'posts' );
/**
* Fires after the 'posts' cache group last changed time is
updated.
*
* @since x.x.x
*
* @param string $value The new last changed time.
* @param string|false $previous_value The previous last changed
time.
* False indicates no value
was set.
*/
do_action( 'wp_cache_set_posts_last_changed', $value,
$previous_value );
}
}}}
Persistent cache developers could use the action to clear cache keys via
wildcard.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/57625#comment:6>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list