Files
pack/buildkit/build_llb/cache_store.go
T
zeekay 7844a60aff refactor(pack): modernize to github.com/hanzoai/pack and remove upstream branding
- Migrate module path to github.com/hanzoai/pack across all Go packages
- Remove legacy upstream docs and competitor brand references
- Modernize LLM.md and mise.toml for pristine Hanzo Pack builder
2026-09-04 00:40:42 -07:00

50 lines
896 B
Go

package build_llb
import (
"fmt"
"github.com/moby/buildkit/client/llb"
"github.com/hanzoai/pack/core/plan"
)
type BuildKitCache struct {
cacheKey string
planCache *plan.Cache
cacheState *llb.State
}
type BuildKitCacheStore struct {
uniqueID string
CacheMap map[string]BuildKitCache
}
func NewBuildKitCacheStore(uniqueID string) *BuildKitCacheStore {
return &BuildKitCacheStore{
uniqueID: uniqueID,
CacheMap: make(map[string]BuildKitCache),
}
}
func (c *BuildKitCacheStore) GetCache(key string, planCache *plan.Cache) BuildKitCache {
cacheKey := key
if c.uniqueID != "" {
cacheKey = fmt.Sprintf("%s-%s", c.uniqueID, key)
}
if cache, ok := c.CacheMap[cacheKey]; ok {
return cache
}
cacheState := llb.Scratch()
cache := BuildKitCache{
cacheKey: cacheKey,
planCache: planCache,
cacheState: &cacheState,
}
c.CacheMap[cacheKey] = cache
return cache
}