跳到內容
AggregaAggregaAggregaAggrega
選擇語言: 繁體中文
本頁為機器翻譯。閱讀英文原文。

aggrega cache

檢視並維護磁碟上的快取

概要

aggrega cache

說明

Inspect and maintain the caches the compiler populates.
status lists cache contents, one element per line, then a summary line.
prune reclaims artifact-cache entries no workspace lockfile references.
evict trims the compiled-module cache to a size cap, oldest first.
clear wipes every cache, including the compiled-module store.

子命令

命令說明
aggrega cache clear清除所有快取,包括已編譯的模組
aggrega cache evict將已編譯模組的快取修剪到大小上限,從最舊的開始
aggrega cache prune移除沒有任何鎖定檔參照的成品快取項目
aggrega cache status列出快取內容與總計概要

aggrega cache clear 說明

Wipe every cache: the workspace artifact cache (entities, source artifacts,
external inputs) and the caches every project on the machine shares (compiled
modules, plugin descriptors, documentation bundles, and the cli plugins added
where no workspace was found). This is the total-wipe verb; unlike prune it
reclaims the compiled-module cache and the documentation bundles as well.
Cleared caches repopulate on the next build, and the documentation bundle on
the next read of the documentation; a cli plugin cleared from the cache is
fetched again by adding it again.
Because the wipe is irreversible, clear asks for confirmation before removing
anything. Pass --yes to skip the prompt for non-interactive use; without --yes
on a non-interactive stdin it refuses rather than blocking on a prompt no one
can answer.

aggrega cache clear 旗標

旗標預設說明
--yesfalse略過確認提示(供非互動式/CI 使用)

aggrega cache evict 說明

Trim the compiled-module cache to a size cap by removing the
least-recently-compiled modules first, until the cache total is at or below
--max-size. The compiled-module cache is machine-global: every provider guest is
compiled once and reused across every project on the machine, so over time it can
dominate on-disk cache use.
Unlike prune (which reclaims artifact-cache entries no lockfile references) and
clear (which wipes every cache), evict is size-bounded and touches only the
compiled-module cache. Evicted modules recompile on demand on the next build, so
eviction loses no irrecoverable state.
--max-size is required and accepts a binary-unit size in the same vocabulary the
status summary prints — for example 5GiB, "4.5 GiB", or 512MiB — or a bare
integer byte count. The unit suffix is case-insensitive and an optional space
may separate the number from the unit.
This verb is the on-demand trim, at a cap you give it once. The cache is also
held to a standing cap without being asked: every invocation that loads a plugin
applies the `compiled_module_cache.max_bytes` setting (53687091200 bytes, 50 GiB,
by default) before it compiles anything, using this same removal order. Use this
verb to reclaim space now or below the standing cap; change the setting to move
the standing cap itself. When the cache already fits the cap, evict reports a
no-op and removes nothing.

aggrega cache evict 旗標

旗標預設說明
--max-size—已編譯模組快取的大小上限(例如 5GiB、512MiB,或位元組數);必要

aggrega cache prune 說明

Remove cache entries whose content digest no workspace lockfile references,
retaining every referenced entry. The reference set is the union of the
digests pinned across every lockfile (*.lock) in the workspace, together with
the digests the configuration's plugins.cli list pins, so a cli plugin you
added keeps the bytes it runs from.
Prune acts on the caches whose entries carry a content digest — the workspace
artifact cache (entities, source artifacts, external inputs), the
plugin-describe cache and the cli-plugin cache, which holds the cli plugins
added where no workspace was found — and on the compiled-module cache by reference: a compiled
plugin module is reclaimed when no lockfile still references the plugin it
belongs to, and the shared runtime module every plugin depends on is reclaimed
once the last plugin referring to it is pruned. A compiled module that cannot be
traced back to a plugin is retained rather than removed on a guess; that
remainder is reclaimed by "aggrega cache evict" or "aggrega cache clear".
Prune needs a pulled workspace: it fails when no lockfile is present.

aggrega cache status 說明

List the contents of every cache, one element per line, followed by a
summary line of the form "N elements, <human size>". The listing is
deterministic: identical cache state produces byte-identical output.

快取是什麼,以及它不是什麼

artifact_cache_dir(預設為 .aggrega/cache)之下的成品快取,存放擷取所放入的內容:目錄實體與來源成品,各自依其種類以及擷取時的座標與版本儲存,並由鎖定檔記錄的摘要背書。它不是目錄資料夾,目錄掃描會略過它——所以位於快取中的內容是透過為它背書的固定被當作相依性讀取,絕不會被當作你撰寫的實體。

**你最可能遇到的後果。**如果快取中有一個沒有任何鎖定檔固定的實體,該實體對建置而言是看不見的,而需要它的建置會中止並說明找不到它。該中止訊息會指名該實體,所以從訊息就能辨識出缺少的固定。

當該實體是 $ref: 所觸及的 SchemaLibrary 時,每個將該參照回報為未解析的命令,都會在回報之後接一行 remediation:,指名快取持有、但沒有任何鎖定檔項目固定、也沒有任何目錄資料夾提供的每個程式庫,以及對該命令有效的做法:

  • aggrega build 與 aggrega validate --release <release> 會讀取 Release 的鎖定檔,所以該行指名 aggrega pull --release <release>,以解析該程式庫並記錄它的項目。
  • 不帶引數的 aggrega validate,以及帶或不帶 --release 的 aggrega validate <entity-path>,只從目錄資料夾讀取程式庫,也不讀取任何鎖定檔,所以沒有任何已記錄的項目會改變它們的裁決。該行會這麼說,並指名先執行 aggrega pull --release <release>,再執行 aggrega validate --release <release>,後者會依 Release 的鎖定檔所固定的內容來檢查它。
  • aggrega pull 與 aggrega build --auto-pull 在離線態勢下,既無法擷取該程式庫,也無法為它記錄項目,所以該行會說要在能連上登錄庫的地方執行 aggrega pull --release <release>。連線時,若 pull 在任何目錄資料夾與它所讀取的任何登錄庫中都找不到該程式庫,就沒有可記錄的項目。

這些行每一行也都提供另一條出路:把程式庫撰寫在目錄資料夾之下。

該執行什麼。aggrega pull --release <release> 會解析該實體並記錄它的摘要,之後同一個建置就能找到它。若該實體是你自己的、而不是相依性,請改為把它撰寫在 workspace.catalog_dirs 所列的目錄之下——掃描會讀取那裡。aggrega cache prune 會清除沒有任何鎖定檔參照的項目,這是同一條規則中整理的那一半。

關於快取配置、artifact_cache_dir 契約,以及為什麼刻意讓解析成品無法被當作撰寫內容讀取,請見 architecture/13-catalog-and-registry.md。

哪些快取屬於這個專案,哪些屬於這台機器

這些命令所作用的快取,並非每一個都以你目前所在的專案為範圍,而這個差異決定了回收能涵蓋多遠。

僅屬於你。artifact_cache_dir 之下的成品快取——這個專案已解析的實體、來源成品與已固定的外部輸入,以及未指名目錄資料夾的匯入所讀取的已發布目錄快照。從中回收只會影響這個專案,不影響其他任何東西。

**由這台機器上的每個 Aggrega 專案共用。**已編譯模組儲存區、外掛程式描述儲存區、文件套組儲存區與 cli 外掛程式儲存區。提供者客體只編譯一次,並由每個專案重用,這正是任何東西第二次建置會很快的原因,所以移除一個項目,表示這台機器上任何專案的下一次建置都會重新編譯它。文件套組——aggrega explain、編輯器的說明與助理的文件資源所讀取的已發布頁面,以及 aggrega draft --example 寫出的可執行範例——依登錄庫與版本各保存一份,因為它的內容不依賴其他任何東西:它們之中誰先擷取,就為每個專案擷取,而每個專案仍然只有在自己的簽章檢查接受該副本之後,才會取得它。沒有任何東西會永久遺失——被移除的模組會依需要重建,被移除的套組會由下一次說明或範例,或在助理伺服器下次啟動時,再次擷取——但成本會落在下一個建置的人身上,那可能不是你。

cli 外掛程式儲存區存放每個以 aggrega plugin add cli 在不屬於任何工作區的資料夾中加入的 cli 外掛程式的位元組,所以它的命令可以在任何資料夾執行;在工作區內加入的 cli 外掛程式,則改為把它的位元組保存在該工作區的成品快取中。與已編譯模組或套組不同,位元組被移除的 cli 外掛程式不會自行再次被擷取:在 aggrega plugin add cli <name> 再次加入它之前,它的命令會遺失,而每個命令都會警告它無法被加入,並指名以你的設定所固定的版本再次加入它的 aggrega plugin add cli 命令。

機器範圍的儲存區保存在各平台存放使用者快取的位置:在 Windows 上,位於環境變數 LOCALAPPDATA 所指名之目錄內的 aggrega\cache 之下;在 macOS 上位於 ~/Library/Caches/aggrega;在 Linux 與其他 Unix 系統上,位於 XDG_CACHE_HOME 所指名之目錄內的 aggrega 目錄之下——XDG_CACHE_HOME 未設定時則為 ~/.cache/aggrega。aggrega config init 會印出它在所執行之機器上的目錄。當這些變數都沒有設定時,已編譯的外掛程式只在該次執行期間保存,而且完全不保存文件套組:此時說明會告知它的逐步說明為何遺失,助理的文件資源回答找不到,aggrega draft --example 會拒絕並說明沒有可解析的快取目錄;在不屬於任何工作區的資料夾中執行的 aggrega plugin add cli 也會拒絕,並說明沒有可解析的機器範圍快取位置。

aggrega cache status 會依類別說明這一點,而不是讓你從名稱去推斷:每個類別都被回報為涵蓋工作區或涵蓋機器,而 prune、evict 與 clear 所移除的每個元素,也都回報相同的涵蓋範圍。evict 只作用於共用的已編譯模組儲存區;prune 從不移除文件套組或匯入所讀取的目錄快照,因為沒有任何鎖定檔參照其中任何一個,並把每個這樣的類別回報為不適用 prune;prune 會保留你設定的 plugins.cli 清單所固定的每個 cli 外掛程式的位元組——無論在 cli 外掛程式儲存區或工作區的成品快取中,連同它的外掛程式描述項目——並移除沒有任何固定指名的那些;clear 作用於一切,這就是它在開始之前會先詢問的原因。

**無法使用的工作區根目錄。**當命令所收到的工作區根目錄是檔案,或是不存在的路徑時,status、evict 與 clear 只作用於機器範圍的儲存區,以它們原本會有的結束代碼結束,並在標準錯誤上說明此事,所用的措辭與每個其他命令拒絕該根目錄時相同:

note: —workspace-root names the workspace root "<root>", which is not a directory: <root>; only the machine-wide caches are acted on(註:—workspace-root 指名了工作區根目錄,但它不是目錄;只會作用於機器範圍的快取)

不存在的路徑,會以 which cannot be used: 與原因來取代 which is not a directory:。prune 則會停止,因為它需要工作區的鎖定檔。

**無論該操作從哪裡叫用,這都適用,不只在終端機。**同樣的操作也能從編輯器工作階段與助理的工具呼叫觸及,而且基於同樣的理由,它們的回答帶有相同的涵蓋範圍。關於助理何時可以代你叫用它們,請見 aggrega mcp。

成品快取目錄是快取中所有內容被讀取、寫入與移除的唯一位置——預設的 .aggrega/cache,與 artifact_cache_dir 所指名、越出工作區根目錄的目錄(../shared-cache)皆然。其中任何指向該目錄之外的符號連結——快取自己的目錄之一,例如 .aggrega/cache/inputs,或其中的檔案——都不會被讀取、寫入或透過它移除,即使該連結指向同一個工作區的另一個目錄也一樣。寫入可以觸及快取目錄之下的範圍,與移除可以觸及的範圍完全相同。

  • pull、建置與其他每個寫入快取的操作會以 E0320 停止,指名該連結與它的指向,且不寫入任何東西。
  • status、prune 與 clear 不會透過這樣的連結列出任何東西。當快取自己的目錄之一就是該連結時,status 會以 E0321 停止,而 prune 或 clear 會在列出或移除任何東西之前以 E0320 停止——所以連結所指的東西不會被移除,連結也留在原處。當其中的檔案是該連結時,這三者都會以 E0321 停止。
  • 建置、pull 與其他每個讀取快取的操作會以 E0321 停止,而不是讀取保存在別處的位元組,即使那些位元組會與鎖定檔記錄的摘要相符也一樣。
  • **停留在快取目錄內的連結會被依循。**當快取自己的目錄之一是連結到快取目錄內另一個目錄時,那個目錄就是快取的:status 會列出那裡的內容,prune 會從那裡移除,而 clear 會清空它、保留連結,並回報它在那裡移除的位元組。

**快取目錄本身。**寫在工作區根目錄內的 artifact_cache_dir——包括預設值——本身可以是連結到工作區另一個目錄的連結,此時快取就保存在連結所指之處。指向工作區之外的則會被拒絕:無論哪個操作遇到它,都會在透過它讀取或寫入任何東西之前,以 E0321 或 E0320 停止並指名該連結。寫成越出工作區根目錄的目錄,會依其所指之處受到遵從,即使它本身就是連結也一樣。

移除該連結並再次 pull,即可就地填入快取。若要把快取保存在別處,請把 artifact_cache_dir 設為該目錄,並相對於工作區根目錄書寫,而不是連結到它:那裡所指名的目錄會在它所指之處被讀取與寫入。機器範圍的儲存區不受任何工作區約束;你透過連結保存在別處的儲存區,會在連結所指之處被列出、修剪與清除,而 clear 會保留該連結。工作區邊界完整陳述了這條規則。

另請參閱

  • aggrega-pull — 將 Release 的相依性解析到鎖定檔與快取中。
  • aggrega-config — artifact_cache_dir 與其他快取設定的撰寫位置。