Documentation ¶
Overview ¶
The filecache package provides a file-based shared durable blob cache.
The cache is a machine-global mapping from (kind string, key [32]byte) to []byte, where kind is an identifier describing the namespace or purpose (e.g. "analysis"), and key is a SHA-256 digest of the recipe of the value. (It need not be the digest of the value itself, so you can query the cache without knowing what value the recipe would produce.)
The space budget of the cache can be controlled by SetBudget. Cache entries may be evicted at any time or in any order. Note that "du -sh $GOPLSCACHE" may report a disk usage figure that is rather larger (e.g. 50%) than the budget because it rounds up partial disk blocks.
The Get and Set operations are concurrency-safe.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrNotFound = fmt.Errorf("not found")
ErrNotFound is the distinguished error returned by Get when the key is not found.
Functions ¶
func BugReports ¶
BugReports returns a new unordered array of the contents of all cached bug reports produced by this executable. It also returns the location of the cache directory used by this process (or "" on initialization error).
func Get ¶
Get retrieves from the cache and returns the value most recently supplied to Set(kind, key), possibly by another process. Get returns ErrNotFound if the value was not found.
Callers should not modify the returned array.
func SetBudget ¶
SetBudget sets a soft limit on disk usage of regular files in the cache (in bytes) and returns the previous value. Supplying a negative value queries the current value without changing it.
If two gopls processes have different budgets, the one with the lower budget will collect garbage more actively, but both will observe the effect.
Even in the steady state, the storage usage reported by the 'du' command may exceed the budget by as much as a factor of 3 due to the overheads of directories and the effects of block quantization, which are especially pronounced for the small index files.
Types ¶
This section is empty.