-
Notifications
You must be signed in to change notification settings - Fork 61
Delete all caches or support bulk cache deletion using filters #20
Comments
Hi @RSickenberg 👋🏽 Thank you for your wonderful suggestion! :) Currently we are planning for some enhancements on the current CLI on making it better and I've added your suggestion in list. We will prioritise based on the urgent needs and feedback from other users. In the meantime, in case you wish to contribute, please feel free to raise a Pull Request for your suggested feature and we will be happy to review the same. Thanks! :) |
In case it's useful to anyone, I was able to do this with this snippet:
Unfortunately, it's kinda slow. Took a couple minutes to delete 250 cache entries. |
Any update @kotewar? I'd love to see this progress soon. My use case is that I would like to delete the cache on working branches if they are older than x days - thus leaving them in place for working branches until after they merge. Still, I need to leave them in case the branch gets changed after an initial merge to a protected branch such as staging or main. So I really need to be able to filer by x hours/days and also filter by "branch != main, staging, other-protected-branches." - this does not need to be branches that are listed under branch protection rules per se, I am fine with specifying them in the workflow. if I had this, I think I could get all branches older than X days. Then I could filter out the ones that have my protected branch names with a pipe to grep and a well-crafted regex. But it would also be great to have a negative filter on branch name(s) as well. I don't see an issue that asks for that but is it in your work plan? If not, I can open an issue (or point me to one and I will comment/upvote it) The concept is this "get rid of all branches older than X that are not on branches main, staging, XYZ" and without having to get into scripting, etc. |
Hey @tpak, 👋🏽 Unfortunately no update yet. This kind of functionality needs support from the backend side and we don't have any APIs in place yet that support bulk deletion of caches which can make this faster than the alternative suggested above. I'll add this request in our backlog so that we can support bulk deletion of caches given the filters. |
Thanks for the update @kotewar I guess I need bulk delete but as I re-read it, I'm seeking to filter better on dates both for list and delete operations. Unfortunately, as it currently stands there is no filtering capability for the list or delete operations. For delete, it would translate as "bulk" but for list it would materialize as a filter. The return from list operations I'll re-read existing issues and maybe open a new one for list filters |
@tpak , list capability does support filtering by cache name, branch and sorting by last-used, size, created-at. You can provide filters with the list command as shown in the documentation. Although I understand what you are trying to refer here. I went through your recently created issues #51 and #52. We will add these to our backlog. |
Thanks @kotewar. Yes, I am aware of the current filter and sort options, but unfortunately, as outlined in 51 and 52, the current filter and sort capabilities are not quite up to the task at hand. Those will make great upgrades. |
For anyone stumbling on the same issue, another option to |
I came across this issue while looking how to delete all caches, didn't see it mentioned here but the github cli now supports this via:
|
I had the same problem as OP and came up with the following command to delete cache entries that have not been accessed after a certain date: gh cache list -R OWNER/REPO | awk '$5 < "2023-11-28"' | cut -f2 | xargs -I {} gh cache delete -R OWNER/REPO {} You can even set the following alias which is more handy: gh alias set --shell 'cache prune' 'gh cache list -R "$1" | awk -v date="$2" '\''$5 < date'\'' | cut -f2 | xargs -I {} gh cache delete -R "$1" {}' Then run the command with : gh cache prune OWNER/REPO 2023-11-28 This also works with time: gh cache prune OWNER/REPO 2023-11-28T12:00 This last example will delete cache objects last accessed before Nov. 28 2023 at 12:00 (UTC) on the given repo. Note that I use the last access date but if you want to filter on the cache object creation date you can just replace Hope this helps! |
In continue to @tbenthompson suggestion, I used the following snippet to delete cache files that contain certain keywords: |
👋 This extension is being deprecated in favor of the built-in This is supported in |
Describe the feature or problem you’d like to solve
It would be cool to add a flag if we want to delete all cache from a repo or with some filters like older than x, bigger than x, and so on.
Proposed solution
The solution would help to gain time between the list command and the delete command.
Regards :)
The text was updated successfully, but these errors were encountered: