runs-on / cache

Shockingly faster GitHub Action cache with S3 backend
https://runs-on.com
MIT License
61 stars 12 forks source link

Allow controlling the cache eviction time #7

Closed Moxinilian closed 6 months ago

Moxinilian commented 6 months ago

We have a potential use case for this where we have a very costly compile for a rarely changing dependency library that we would like to keep for a long time, potentially clearing it up manually when it becomes unused (or, rather, have it be cleared after a month or two).

Is it currently possible to specify how long a cached item should live?

ruffsl commented 6 months ago

It would be kind of cool to be able to assign a life-time on a per-cache basis when saving the cache, much like how the retention-days: parameter works with the actions/upload-artifact action. However, as one user to another, we may be better off just adding to the default life-time policy for the S3 bucket.

You could give your cache a certain prefix or post-fix, such that a custom life-time policy could be prioritized for those matching caches. I think the default one (ExpireCache) is just to evict anything older than 10 days.

That said, I'm not sure Lifecycle configurations for AWS S3 buckets can be given priorities like ECR lifecycle policies. So perhaps some server side feature would be necessary.

crohr commented 6 months ago

@Moxinilian As @ruffsl commented, you would be better off configuring S3 lifecycle rules for this. They are quite flexible. There is no proper way to assign a TTL to S3 object, as far as I know.