1package solver 2 3import ( 4 "context" 5 "time" 6 7 "github.com/moby/buildkit/session" 8 digest "github.com/opencontainers/go-digest" 9 "github.com/pkg/errors" 10) 11 12var ErrNotFound = errors.Errorf("not found") 13 14// CacheKeyStorage is interface for persisting cache metadata 15type CacheKeyStorage interface { 16 Exists(id string) bool 17 Walk(fn func(id string) error) error 18 19 WalkResults(id string, fn func(CacheResult) error) error 20 Load(id string, resultID string) (CacheResult, error) 21 AddResult(id string, res CacheResult) error 22 Release(resultID string) error 23 WalkIDsByResult(resultID string, fn func(string) error) error 24 25 AddLink(id string, link CacheInfoLink, target string) error 26 WalkLinks(id string, link CacheInfoLink, fn func(id string) error) error 27 HasLink(id string, link CacheInfoLink, target string) bool 28 WalkBacklinks(id string, fn func(id string, link CacheInfoLink) error) error 29} 30 31// CacheResult is a record for a single solve result 32type CacheResult struct { 33 CreatedAt time.Time 34 ID string 35} 36 37// CacheInfoLink is a link between two cache keys 38type CacheInfoLink struct { 39 Input Index `json:"Input,omitempty"` 40 Output Index `json:"Output,omitempty"` 41 Digest digest.Digest `json:"Digest,omitempty"` 42 Selector digest.Digest `json:"Selector,omitempty"` 43} 44 45// CacheResultStorage is interface for converting cache metadata result to 46// actual solve result 47type CacheResultStorage interface { 48 Save(Result, time.Time) (CacheResult, error) 49 Load(ctx context.Context, res CacheResult) (Result, error) 50 LoadRemote(ctx context.Context, res CacheResult, s session.Group) (*Remote, error) 51 Exists(id string) bool 52} 53