Documentation
¶
Overview ¶
Package checkpoint provides a small file-based cache for resumable, task-oriented CLIs: Recover loads a previously Commit-ed value by key, or returns the supplied default if no cache is configured or the value is missing/unreadable.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Commit ¶
Commit persists val under key in the default Cache (see Default/SetDefault). It is a no-op if no cache directory is configured.
func Recover ¶
Recover loads the value previously stored under key by Commit, using the default Cache (see Default/SetDefault). It returns def if no cache directory is configured, the key is unknown, or the cached value cannot be read or decoded (in the latter cases, the optional WithWarn callback is invoked).
func SetDefault ¶
func SetDefault(c *Cache)
SetDefault replaces the package-level Cache used by Recover/Commit.
Types ¶
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
Cache is a directory-backed, SHA1-keyed YAML cache. The zero value and a nil *Cache are both safe to use: Recover returns the default value and Commit is a no-op.