Skip to content

Pass additional restore-keys to cache action #366

Closed as not planned
Closed as not planned

Description

@gustavovnicius

As can be seen in their examples: https://github.com/actions/cache/blob/main/examples.md#java---gradle

It is recommended that additional restore-keys are passed when using actions/cache. https://github.com/actions/cache#inputs

https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#matching-a-cache-key

const matchedKey = await cache.restoreCache(packageManager.path, primaryKey);
could be changed to something like:

const restoreKey = `${CACHE_KEY_PREFIX}-${process.env['RUNNER_OS']}-${packageManager.id}`;
const matchedKey = await cache.restoreCache(packageManager.path, primaryKey, [restoreKey]); 

Activity

  1. gustavovnicius commented on Aug 12, 2022

    @gustavovnicius
    Author

    I see that this: #285 was recently merged, but the cost doesn't outweigh the gains.

    It is not realistic to bust the cache completely whenever a version changes. Many projects nowadays rely on automated dependency updates, not using restore-keys makes the performance of setup-java unacceptably bad in those cases.

    A better way to handle this would be to expose an input to let people decide how often they want to expire their caches.

  2. self-assigned this
    on Aug 15, 2022
  3. dsame commented on Aug 15, 2022

    @dsame
    Contributor

    Hello @gustavovnicius
    Thanks for your input, i am starting to investigate the problem.

  4. dsame commented on Aug 15, 2022

    @dsame
    Contributor

    @gustavovnicius the cache should be updated whenever the dependencies changed. It is expected behaviour and actually it is not realistic the update of dependencies happens too often.

    Nevertheless for some specific use cases it is natural to use full-featured https://github.com/actions/cache actions instead of its simplified implementation built-in into setup-java action.

  5. added
    feature requestNew feature or request to improve the current logic
    and removed
    feature requestNew feature or request to improve the current logic
    on Aug 15, 2022
  6. paramaggarwal commented on Aug 19, 2022

    @paramaggarwal

    The PR #285 should be reverted. It makes caching useless unless the code is exactly the same.

  7. gustavovnicius commented on Aug 19, 2022

    @gustavovnicius
    Author

    What I'm proposing on #367 is a solution that works both ways.
    Having a customizable cache key prefix gives it enough flexibility to be used in many different setups.

  8. dsame commented on Aug 22, 2022

    @dsame
    Contributor

    The PR #285 should be reverted. It makes caching useless unless the code is exactly the same.

    The cache must be renewed if any dependency has changed. In the other case the cache keeps obsolete dependencies and grows infinitely.

  9. dsame commented on Aug 22, 2022

    @dsame
    Contributor

    What I'm proposing on #367 is a solution that works both ways. Having a customisable cache key prefix gives it enough flexibility to be used in many different setups.

    Built-in cache is not intended to be flexible, it is intended to work out of box in the most cases. For the specific complex caching that requires flexibility and customisation there's https://github.com/actions/cache action

  10. dsame commented on Aug 22, 2022

    @dsame
    Contributor

    The feature request is declined because the requested functionality exist in the other action https://github.com/actions/cache

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

feature requestNew feature or request to improve the current logic

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions