๐Ÿ“ฆ bradfitz / go-tool-cache

โ˜… 120 stars โ‘‚ 26 forks ๐Ÿ‘ 120 watching โš–๏ธ BSD 3-Clause "New" or "Revised" License
๐Ÿ“ฅ Clone https://github.com/bradfitz/go-tool-cache.git
HTTPS git clone https://github.com/bradfitz/go-tool-cache.git
SSH git clone git@github.com:bradfitz/go-tool-cache.git
CLI gh repo clone bradfitz/go-tool-cache
Brad Fitzpatrick Brad Fitzpatrick gocached: batch access time updates, reducing SQLite write mutex contention fef72b9 1 months ago ๐Ÿ“ History
๐Ÿ“‚ main View all commits โ†’
๐Ÿ“ cacheproc
๐Ÿ“ cachers
๐Ÿ“ cmd
๐Ÿ“ gocached
๐Ÿ“ wire
๐Ÿ“„ .gitignore
๐Ÿ“„ go.mod
๐Ÿ“„ go.sum
๐Ÿ“„ LICENSE
๐Ÿ“„ README.md
๐Ÿ“„ README.md

go-tool-cache

Do you like Go's built-in build & test caching but wish it weren't purely stored on local disk in the $GOCACHE directory?

Want to share your cache over the network between your various machines, coworkers, and CI runs without all that GitHub actions/caches tarring and untarring?

Go's GOCACHEPROG lets you do that!

This was a demonstration repro for when GOCACHEPROG was still a proposal. Now it just contains some misc examples.

Status

GOCACHEPROG shipped as an experiment in Go 1.21. It became official in Go 1.24.

Using

First, build your cache child process. For example,

$ go install github.com/bradfitz/go-tool-cache/cmd/go-cacher@latest

Then tell Go to use it:

$ GOCACHEPROG=$HOME/go/bin/go-cacher go install std

See some stats:

$ GOCACHEPROG="$HOME/go/bin/go-cacher --verbose" go install std
Defaulting to cache dir /home/bradfitz/.cache/go-cacher ...
cacher: closing; 548 gets (0 hits, 548 misses, 0 errors); 1090 puts (0 errors)

Run it again and watch the hit rate go up:

$ GOCACHEPROG="$HOME/go/bin/go-cacher --verbose" go install std
Defaulting to cache dir /home/bradfitz/.cache/go-cacher ...
cacher: closing; 808 gets (808 hits, 0 misses, 0 errors); 0 puts (0 errors)