module
Noir::CLI::CacheCommand
Overview
noir cache <info|clear|purge>
Managed resource: the on-disk LLM response cache.
Defined in:
cli/commands/cache.crConstant Summary
-
ACTIONS =
["info", "clear", "purge"] of ::String -
MAX_PURGE_DAYS =
36500 -
Upper bound on
noir cache purge <days>. 100 years is well past any realistic cache retention horizon; the actual reason for the cap is Crystal'sTime.utc - <days>.daysarithmetic, which raisesArgumentError: Invalid time: seconds out of rangefor values that push the resulting Time past the supported range. 100 years stays comfortably inside the Time bounds.
Class Method Summary
- .clear(io : IO = STDOUT)
-
.format_age(t : Time) : String
Public for the same reason as
.format_bytes. -
.format_bytes(bytes : Int64) : String
Public so the unit ladder (B/KB/MB/GB) can be exercised directly, matching the testability philosophy the rest of this module follows.
- .parse_argv(argv : Array(String)) : Parsed
-
.parse_days(arg : String | Nil) : Int32 | Nil
Returns
dayswhenargis a positive integer within the representable Time range,nilotherwise. - .print_help(io : IO = STDOUT)
- .print_info(io : IO = STDOUT)
- .purge(rest : Array(String), io : IO = STDOUT)
- .run(argv : Array(String))
Class Method Detail
Public for the same reason as .format_bytes. Clamps to 0 for a
future-dated t (clock skew, an NTP jump, a manually touch'd
file) so the display never shows a negative "-3599s ago" that reads
like a parsing bug.
Public so the unit ladder (B/KB/MB/GB) can be exercised directly, matching the testability philosophy the rest of this module follows.
The unit decision compares against the rounded value, not the raw one: just below a 1024 boundary the raw value stays under 1024 while rounding to one decimal lands on 1024.0, which printed as e.g. "1024.0 KB" instead of rolling over to "1.0 MB".
Returns days when arg is a positive integer within the
representable Time range, nil otherwise. Pulled out of .purge
so the validation rule can be exercised without going through
the die exit path.