actions / actions/cache

Provide a mechanism to have a per file cache eviction/retention

Open
#788 11 comments 12 reactions 1 assignee View on GitHub

@tiwarishub is already working on this.

Since May 7, 2022.

feature request
Dominant language
TypeScript
Stars
5.6k
Forks
1.6k
PR merge metrics
No merged PRs in 30d

Description

This is related to issue https://github.com/actions/setup-java/issues/269

The problem is that caches fill up over time as dependencies, runtimes, and tooling are upgraded. Old files are never evicted and the cache grows. The current solution is to recalculate the cache-key at every build (base it on the week number or such) and throw it all away, but that works against the purpose of a cache to begin with.

I suggest that when saving the caches we should be able to evict files older than a configurable number of days. That way old dependencies will be removed over time and we can have the best of both worlds.

PS. I'm not sure how the cache-hit logic works in this scenario.

Something like this:

- name: Configure Gradle JDK cache
    uses: actions/cache@v3
    with:
      path: ~/.gradle/jdks
      key: gradle-jdks-${{ runner.os }}
      # Evict files older than 30 days from the cache and repackage.
      eviction:
        include:    # required, we don't want to remove just any file and corrupt the cache
          - **/*.zip
          - **/*.jar
          - **/*.tar
        days: 30

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.