question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Make Cache Key Optional?

See original GitHub issue

Is it possible to make the key optional and hence make the cache action read-only? This is in the case that you know that you only want to read from one of the “restore” keys and to fail if you can’t find one.

For clarity, look for restore key patterns only:

On cache hit - read the cache, don’t attempt to write a new one. On cache miss - job fail.

An alternative could be to recognize a specific string as the key which means skip the write on job completion:

      uses: actions/cache@v1
      with:
        path: cache
        key: donotwrite
        restore-keys: myexpectedcache-

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:7
  • Comments:6

github_iconTop GitHub Comments

2reactions
luigi311commented, May 27, 2020

This would be nice. I have a use case where on job 1 I download a file off a server and then create a cache of said file with the key file-${{ hashFile(file) }}, on job 2 I need to do a restore on that exact key but the file does not exist in job 2 and I don’t want to download the file every single time so I want to call a cache restore with the restore key of file- so it does a partial match and restores the lastest key. The problem with the current implementation is I need to generate a bogus unique key for every single run so I don’t get a cache hit and restore a version that might not be valid but then I’m storing the same file over and over with different bogus keys.

0reactions
github-actions[bot]commented, Dec 4, 2022

This issue was closed because it has been inactive for 5 days since being marked as stale.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Spring Caching - ignore parameter for key - Stack Overflow
Save this question. Show activity on this post. I want to cache the results of a simple getter that has an optional parameter...
Read more >
Controlling the cache key - Amazon CloudFront
In the Cache key and origin requests section, make sure that Cache policy and ... This is optional, but it can help you...
Read more >
Create custom cache keys - Cloudflare Docs
Under Then the settings are, choose Custom Cache Key from the dropdown. Click the appropriate Query String setting. (Optional) Click ...
Read more >
Cache.keys() - Web APIs - MDN Web Docs
The keys() method of the Cache interface returns a Promise that resolves to an array of Request objects representing the keys of the...
Read more >
29. Cache Abstraction - Spring
Since caches are essentially key-value stores, each invocation of a cached ... This option comes in handy when an entire cache region needs...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found