mirror of
https://github.com/hanzoai/gocache.git
synced 2026-10-30 18:36:04 +00:00
Implements the GOCACHEPROG protocol (go1.26.4, no GOEXPERIMENT gate) with two tiers: local disk first, S3-compatible object storage on a miss. Results one machine compiles are available to the next. Caches compiles. Link actions are not cached by the go command and are not addressed here. The shared tier is bounded by deadline, disabled after three consecutive failures, and written to through a bounded queue that drops rather than blocks. Unreachable shared storage degrades to a local-only cache; it cannot stall or fail a build. Objects are verified against their output digest before reaching the compiler. Uploads are off by default. Credentials come from KMS, either already in the environment or read directly with a machine identity. No dependencies outside the standard library.
20 lines
617 B
Go
20 lines
617 B
Go
package main
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
"io"
|
|
)
|
|
|
|
// ErrMiss reports that a key is absent. It is distinct from a transport or
|
|
// authorization failure: an absent key means the store is healthy and simply
|
|
// does not have the object, so it must not count against the failure budget
|
|
// that trips the breaker. A cold cache is not a broken cache.
|
|
var ErrMiss = errors.New("miss")
|
|
|
|
// Store is a shared blob store addressed by opaque string keys.
|
|
type Store interface {
|
|
Get(ctx context.Context, key string) (io.ReadCloser, error)
|
|
Put(ctx context.Context, key string, size int64, body io.Reader, hash string) error
|
|
}
|