{"modulePath":"github.com/DomBlack/git-stack","version":"v0.5.0","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package cache\n\nPackage cache stores small JSON documents, per repository under \\\u003cgit-common-dir\u003e/git-stack/ or in a directory of the caller's choosing, so that commands (and completion) can render instantly from the last known state.\n\n## Functions\n\n```go\nfunc Write[T any](s *Store, name string, v T) error\n```\nWrite stores v under name atomically (temp file + rename).\n\n## Types\n\n```go\ntype State int\n```\nState describes the freshness of a cached document.\n\n```go\nconst (\n\t// Missing: no document exists (or it could not be decoded).\n\tMissing State = iota\n\t// Stale: the document exists but is older than the TTL.\n\tStale\n\t// Fresh: the document is within the TTL.\n\tFresh\n)\n```\n\n```go\nfunc Read[T any](s *Store, name string, ttl time.Duration) (T, State, time.Time, error)\n```\nRead loads name. A missing or undecodable file yields the zero value and Missing; a decodable one yields Stale or Fresh depending on ttl. The returned time is when the document was saved.\n\n```go\nfunc (s State) String() string\n```\n\n```go\ntype Store struct {\n\t// contains filtered or unexported fields\n}\n```\nStore is the cache directory of one repository.\n\n```go\nfunc At(dir string) *Store\n```\nAt returns a store rooted at dir, for documents that belong to the user rather than to one repository. Nothing is created until Write.\n\n```go\nfunc New(repo git.Repo) *Store\n```\nNew returns the store for repo. Nothing is created until Write.\n\n```go\nfunc (s *Store) Dir() string\n```\nDir returns the cache directory.\n\n```go\nfunc (s *Store) Path(name string) string\n```\nPath returns the file backing name.\n\n```go\nfunc (s *Store) Remove(name string) error\n```\nRemove deletes name; a missing document is not an error.\n\n","path":"github.com/DomBlack/git-stack/pkg/cache","name":"cache","synopsis":"Package cache stores small JSON documents, per repository under \u003cgit-common-dir\u003e/git-stack/ or in a directory of the caller's choosing, so that commands (and completion) can render instantly from the last known state.","isRedistributable":true}
