lscache_wp icon indicating copy to clipboard operation
lscache_wp copied to clipboard

No support for wp_cache_flush_group()

Open UVLabs opened this issue 5 months ago • 12 comments

The plugin has no support for wp_cache_flush_group():

https://developer.wordpress.org/reference/functions/wp_cache_flush_group/

This is explicitly defined inside this file here: https://github.com/litespeedtech/lscache_wp/blob/master/src/object.lib.php#L331

It's been years since WP added this wp_cache_flush_group(); function...when is this expect to be included?

This affects my workflow because on sites where I have custom plugins, I need to disable the litespeed plugin and install W3 Total Cache simply because sometimes the cache keys I create are dynamic, and the values used to create them are not always available in methods where I would want to clear those cache keys.

Being able to clear the entire group is far more efficient. Any plans on this?

UVLabs avatar Jul 18 '25 20:07 UVLabs

@UVLabs Did you added an answer/created the topic: https://wordpress.org/support/topic/wp_cache_supports-flush_group/ ?

timotei-litespeed avatar Jul 21 '25 12:07 timotei-litespeed

@timotei-litespeed So then can we get this merged? There's way too many changes happening in that pull request to reasonably ask users to manually add the changes to the plugin...

Its almost a year since that pull request was opened @hi-hai

UVLabs avatar Jul 22 '25 14:07 UVLabs

@timotei-litespeed Can you work w/ OP and make sure the PR tested? We can merge this into v7.4

hi-hai avatar Jul 22 '25 14:07 hi-hai

@UVLabs I will remake the PR and share it with you. We will work together on testing it

timotei-litespeed avatar Jul 22 '25 20:07 timotei-litespeed

@timotei-litespeed You can ping me on the updated pull request when done... also let me know how to build the plugin files for production or even better...provide a built zip so i can download

UVLabs avatar Jul 23 '25 12:07 UVLabs

@UVLabs OK :) For all sites we have LSC => Tolbox => Beta test where commits or version can be tested.

I started working here: https://github.com/timotei-litespeed/lscache_wp/tree/OC-improvements

BUT! is note tested! Please do not use it for now

timotei-litespeed avatar Jul 23 '25 18:07 timotei-litespeed

@UVLabs please test with this implementation. https://github.com/timotei-litespeed/lscache_wp/commit/eb6900b70e8ca6c02fd276df38ade89dc0db47d3 Added some Debug messages, which I will remove later.

timotei-litespeed avatar Jul 24 '25 13:07 timotei-litespeed

@timotei-litespeed I can't explain it...But I did a small test on a site with both LSC 7.2 and 7.3 without using your commit, and wp_cache_flush_group seems to be working from the test i did...

I'm looking at the LSC code for v7.3 and it's explicitly stating that it does not have support, yet when I run the test code, WP is not returning false for wp_cache_supports( 'flush_group' )

Here's the test snippet I used:

function sl_cc_test(){
	
	if ( wp_cache_supports( 'flush_group' ) === false ) {
            file_put_contents(ABSPATH . 'log.txt', "no support\n\n", FILE_APPEND);
	}else{
	   file_put_contents(ABSPATH . 'log.txt', "has support\n\n", FILE_APPEND);
	}
	
	  wp_cache_set('testing', 'hello there', 'lsc_group', DAY_IN_SECONDS);

           // Uncomment line below to test cache flush
          // wp_cache_flush_group('lsc_group');

       $cache =  wp_cache_get('testing', 'lsc_group');
	
        if( $cache !== false ) {
            file_put_contents(ABSPATH . 'log.txt', "cache hit\n\n", FILE_APPEND);
        }else{
            file_put_contents(ABSPATH . 'log.txt', "cache miss\n\n", FILE_APPEND);
        }
	
}
add_action('admin_head', 'sl_cc_test');

The log file hows "has support" and when I uncomment the cache flush line, it shows cache miss. So it seems like the cache group is getting cleared somehow...I can't explain whats causing it if LSC specifies no support. I tested from a Namecheap hosting which installs the LSC plugin by default through Softaculous.

Any ideas why its working?

UVLabs avatar Aug 05 '25 21:08 UVLabs

@UVLabs have you tried installing the dev code from this push: https://github.com/timotei-litespeed/lscache_wp/commit/eb6900b70e8ca6c02fd276df38ade89dc0db47d3 ? This can be done from LSC => Toolbox => Beta test => insert the commit in the input and click Update

timotei-litespeed avatar Aug 13 '25 18:08 timotei-litespeed

@timotei-litespeed No i didnt, what im saying is even without adding that commit, LSC seems to work with wp_cache_flush_group as seen in the snippet i provided above. So im wondering how/why?

UVLabs avatar Aug 14 '25 22:08 UVLabs

@timotei-litespeed did you see my last response here?

No i didnt, what im saying is even without adding that commit, LSC seems to work with wp_cache_flush_group as seen in the snippet i provided above. So im wondering how/why?

UVLabs avatar Sep 24 '25 15:09 UVLabs

@UVLabs I saw but I was not able to get to this issue. Thank you for bumping the issue

timotei-litespeed avatar Sep 24 '25 16:09 timotei-litespeed