Skip to content

Add wp cache flush-group for flushing a cache group #85

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Apr 26, 2023
Merged

Add wp cache flush-group for flushing a cache group #85

merged 8 commits into from
Apr 26, 2023

Conversation

janw-me
Copy link
Member

@janw-me janw-me commented Apr 5, 2023

Needs extra input for testing.

I don't know how to create/fake a cache implementation for better behat testing.

Fixes #80

Needs extra input for testing.
@janw-me janw-me requested a review from a team as a code owner April 5, 2023 14:18
* # Clear cache group.
* $ wp cache clear-group my_group
*
* @subcommand clear-group
Copy link
Member

Choose a reason for hiding this comment

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

@spacedmonkey Should it be wp cache clear-group, wp cache delete-group, or wp cache flush-group?

Copy link
Member

Choose a reason for hiding this comment

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

@tillkruss Maybe you might have an opinion on naming ^ ?

Choose a reason for hiding this comment

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

I'd stick with wp cache flush-group to be identical to wp_cache_flush_group(), but I'm a fan of @alias wp cache clear-group.

Copy link
Member

Choose a reason for hiding this comment

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

Hm... I think it should've been named wp_cache_delete_group() in core 😁

flush-group is too close to flush, in my opinion. But, I guess we should be consistent with naming.

@wp-cli/committers Any other opinions to bring into the mix?

Choose a reason for hiding this comment

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

Yeah, alias delete and clear makes sense.

Copy link
Member Author

Choose a reason for hiding this comment

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

Having worked on it a bit more I think I would prefer flush-group it might be close to the existing flush but I think its more consistent that way.

Copy link
Member

Choose a reason for hiding this comment

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

Having worked on it a bit more I think I would prefer flush-group it might be close to the existing flush but I think its more consistent that way.

Sounds good to me 👍

Then STDERR should be:
"""
Warning: Cache group 'false_return' was not be flushed.
"""
Copy link
Member

Choose a reason for hiding this comment

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

I don't know how to create/fake a cache implementation for better behat testing.

@spacedmonkey Are there any cache implementations you're aware of that we could easily install?

Choose a reason for hiding this comment

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

You could use this as upstream: https://github.com/rhubarbgroup/redis-cache/blob/develop/includes/object-cache.php

It will always have the latest Redis implementation ahead of releases.

Copy link
Member

Choose a reason for hiding this comment

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

👍

I might try to find a SQLite implementation so we don't have to add Redis to CI.

Choose a reason for hiding this comment

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

Or APCu.

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

Thank's I'll take a look tomorrow or monday.

Copy link
Member Author

@janw-me janw-me Apr 17, 2023

Choose a reason for hiding this comment

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

https://github.com/OllieJones/sqlite-object-cache does not like WP-CLI....
But I added a mu-plugin that overrides the $GLOBALS['wp_object_cache'].

Ideally a drop-in would be created but that would be bigger then the whole feature test file.
This also works.

@danielbachhuber danielbachhuber changed the title Added group flushing. Add wp cache clear-group for flushing a cache group Apr 6, 2023
@janw-me
Copy link
Member Author

janw-me commented Apr 18, 2023

@danielbachhuber the failed tests are valid, the errors should trigger with older WP versions.
How do we handle this? is a @require-wp-6.1 the way to go?

@danielbachhuber
Copy link
Member

@janw-me Yes, please:

  1. Create entirely separate scenarios.
  2. Add @require-wp-6.1 to the scenarios with the new functionality.
  3. Add @less-than-wp-6.1 to a scenario that tests the error case.

@spacedmonkey
Copy link

@danielbachhuber Where I do personally agree, I think delete group would be better. But there are plugins that used that already so we could not use it. Let's use flush-group, as this is the naming in core, even through it sucks, it sucks in the WordPress way.

Fixed failing test and generated readme file.
Copy link
Member

@danielbachhuber danielbachhuber left a comment

Choose a reason for hiding this comment

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

Looks like just one more minor tweak and then this is ready to 🚢

Then STDOUT should be:
"""
Success: Cache group 'add_multiple' was flushed.
"""
Copy link
Member

Choose a reason for hiding this comment

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

You'll want to move this step to a new scenario so you can control it with @require-wp-6.1

Copy link
Member

@danielbachhuber danielbachhuber left a comment

Choose a reason for hiding this comment

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

Nice work @janw-me 👍

@danielbachhuber danielbachhuber added this to the 2.1.0 milestone Apr 26, 2023
@danielbachhuber danielbachhuber changed the title Add wp cache clear-group for flushing a cache group Add wp cache flush-group for flushing a cache group Apr 26, 2023
@danielbachhuber danielbachhuber merged commit e646bd5 into wp-cli:main Apr 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for wp_cache_flush_group
4 participants