Services.FileCache (fnord v0.9.29)
View SourceGenServer-backed file cache used by AI tools and other services that need to read file contents from the project workspace.
Responsibilities:
- Store {path -> %{sha: sha, content: content}}
- Provide lookup and insert APIs
- Handle concurrent access safely via GenServer
The cache is intentionally simple: it validates freshness by recomputing a sha256 over the file contents when doing a lookup and updates the stored entry when a mismatch is detected.
Summary
Functions
Returns a specification to start this module under a supervisor.
Lookup a cached file by absolute path. Returns {:ok, content} or :miss. The caller should provide a fetch_fun that will be called to obtain actual file contents when the cache is missing or stale.
Directly put content into the cache for a path.
Types
Functions
Returns a specification to start this module under a supervisor.
See Supervisor.
@spec get_or_fetch(String.t(), (-> {:ok, String.t()} | {:error, any()})) :: {:ok, String.t()} | {:error, any()} | :miss
Lookup a cached file by absolute path. Returns {:ok, content} or :miss. The caller should provide a fetch_fun that will be called to obtain actual file contents when the cache is missing or stale.
Directly put content into the cache for a path.
@spec start_link(keyword()) :: GenServer.on_start()