circleci

rm -rf /home/circleci/.gitconfig
vemv 2021-06-29T11:19:02.005Z

I think I ran into a use case for which there's no syntax I want a restore_cache cache key that will last 24h. Rationale being, I don't want to spam an API provider with one request per build. But a permament cache wouldn't be useful either since the API's results can change over time. This is the section that describes the possible syntaxes:

vemv 2021-06-29T11:19:06.005100Z

vemv 2021-06-29T11:19:40.005800Z

the Environment choice would almost cut it

vemv 2021-06-29T11:19:53.006400Z

but it needs fiddling with contexts

borkdude 2021-06-29T11:19:57.006500Z

perhaps you can use the current date as part of the key...?

vemv 2021-06-29T11:20:34.007300Z

yes, that's what I'm seeking but circle's syntax seemingly doesn't allow to embed the output of an arbitrary command there

vemv 2021-06-29T11:21:49.008800Z

a few things could work for me: * ability to use the output of arbitrary commands * allow vanilla env vars, not from contexts * add something akin to epoch, just not so fine-grained

conormcd 2021-06-29T11:22:02.009100Z

The easiest way around that is to echo the output into a file and then use the checksum of that file.

💡 1
👆 1
vemv 2021-06-29T11:30:22.013100Z

I gave it a think and it doesn't sound like it would work for my use case. I need to cache an internal cache dir (this API uses such a cache locally), not a result set. The API itself must be called in every run; caching results would be incorrect In any case I'd really appreciate the declarativeness of saying "dir foo should be cached for 1 day"

borkdude 2021-06-29T11:53:21.014Z

@vemv you can use multiple parts in a key so you could make the key based on dir foo + a file where you write the current date?

👀 1
vemv 2021-06-29T12:38:05.016200Z

@borkdude that worked! and it's pretty thin. might have been what @conormcd suggested? Not sure if I was interpreting incorrectly what he said. Either way thank you both!

👍 1