package filecache
import "cuelang.org/go/internal/golangorgx/gopls/filecache"
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 ¶
- Variables
- func BugReports() (string, []bug.Bug)
- func Get(kind string, key [32]byte) ([]byte, error)
- func Set(kind string, key [32]byte, value []byte) error
- func SetBudget(new int64) (old int64)
- func Start()
Variables ¶
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 Set ¶
Set updates the value in the cache.
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.
func Start ¶
func Start()
Start causes the filecache to initialize and start garbage gollection.
Start is automatically called by the first call to Get, but may be called explicitly to pre-initialize the cache.
Source Files ¶
filecache.go
- Version
- v0.12.0 (latest)
- Published
- Jan 30, 2025
- Platform
- linux/amd64
- Imports
- 18 packages
- Last checked
- 8 hours ago –
Tools for package owners.