I was wondering what the expectations around cache volumes are.
Should I expect the cached volumed to persist between invocations of my program? As in, does each volume entry it persist within the buildkitd instance by the named key?
e.g.
// initialize some golang container in "golang" variable.
golang.
WithMountedCache("/root/.cache/go-build", client.CacheVolume("go-build")).
WithMountedCache("/go/pkg/mod", client.CacheVolume("go-mod")).
WithExec([]string{"go", "build", "./..."})
I tweaked this example for brevity. I've also explored using
go.sumfiles dagger ID as a cache key.
For these static keys, I started out assuming that each time I run my program, the same contents of this volume will persist between runs.
Or is caching just a way to persist state between execs and containers in a single client session?
I ask as I wanted to explore caching Go's module and build cache between invocations of my build program.
However, when I list the contents of the cache (WithExec([]string{"ls", goCache})) it always starts out empty and I get a full build from scratch.
Wondering if my expectations are wrong, or I am doing something wrong, or something isn't working as expected.
Thanks!
