★ bkt: cache command outputs
• 270 words • 2 min • updated
My esteemed friend Michael Diamond wrote bkt1:
bkt (pronounced “bucket”) is a subprocess caching utility written in Rust.
I mentioned it previously as an example on how to create a PKGBUILD for Arch Linux.
Here is the main use case for me:
Assume you have a command that is expensive to run. The command is intended to display information / output about some resources. Even though it’s expensive, its output rarely changes. So that…caching it would be quite beneficial.
For example, a command to list all your cluster nodes alongside some of their properties. Perhaps you need to run that command multiple times a day2.
Enter bkt!
By creating an alias or a wrapper function in your shell (e.g. by adding it to your shell rc file) that uses bkt, you can make subsequent command runs complete faster, by leveraging its cache.
active_gardens_pp () {
bkt --ttl 7d -- {list clusters command} -o json | jq '.[] | select(.active == true and .partition != "private-cloud" and .partition != "gov-cloud")' | mlr --ijson --opprint --barred cat
}The first time I run active_gardens_pp3, it takes several seconds to complete.
The second time, it completes almost instantaneously.
The cache duration can be defined with the --ttl flag. One day or one week or a couple of hours can be sensible defaults, depending on how often you expect the output to change.
And then I should talk about mlr (Miller) another day…
-
In Rust™. And with a domain hack. ↩︎
-
Especially if, like me, you like to often close your tabs to tidy up (whether browser or terminal ones). ↩︎
-
ppstands for pretty-print. ↩︎
Backlinks
- starship: github PR prompt (Jan 30, 2026)
- bkt: bypass cache (May 05, 2025)