Skip to content

[12.x] Add Expired Flag to cache:clear #55642

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

Closed
wants to merge 3 commits into from
Closed

Conversation

onairmarc
Copy link
Contributor

@onairmarc onairmarc commented May 4, 2025

Overview

This PR adds the --expired flag to the cache:clear artisan command. This is useful because expired cache items are not automatically deleted from the cache table once they have expired.

The main thought behind adding this flag is that cache:clear --expired would be run on a set schedule (i.e. daily) inside of routes/console.php.

Usage

  • Running cache:clear --expired will clean up any expired cache items for the DatabaseStore only.
  • When the --expired flag is passed, only expired cache items will be removed from the cache table.
  • This flag will not affect cache items that have not yet expired.
  • If the cache:clear --expired is run on a non-DatabaseStore cache store, the command will run as if --expired was not passed in the first place.

Please let me know if you would like me to make any changes.

Note: An alternative option could be a dedicated command rather than changing behavior based on a flag. If desired, I can make those modifications in this PR.

@onairmarc onairmarc changed the title Add Expired Flag to cache:clear [12.x] Add Expired Flag to cache:clear May 4, 2025
@taylorotwell
Copy link
Member

Thanks for your pull request to Laravel!

Unfortunately, I'm going to delay merging this code for now. To preserve our ability to adequately maintain the framework, we need to be very careful regarding the amount of code we include.

If applicable, please consider releasing your code as a package so that the community can still take advantage of your contributions!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants