Class: Factorix::CLI::Commands::Cache::Stat
- Inherits:
-
Base
- Object
- Dry::CLI::Command
- Base
- Factorix::CLI::Commands::Cache::Stat
- Includes:
- Formatting
- Defined in:
- lib/factorix/cli/commands/cache/stat.rb,
sig/factorix/cli/commands/cache/stat.rbs
Overview
Display cache statistics
This command outputs statistics for all cache stores in a human-readable or JSON format.
Instance Attribute Summary collapse
-
#logger ⇒ Dry::Logger::Dispatcher
readonly
Returns the value of attribute logger.
Instance Method Summary collapse
-
#call(json:) ⇒ void
Execute the cache stat command.
Methods included from Formatting
#format_duration, #format_size
Methods inherited from Base
backup_support!, confirmable!, inherited, require_game_stopped!
Instance Attribute Details
#logger ⇒ Dry::Logger::Dispatcher (readonly)
Returns the value of attribute logger.
10 11 12 |
# File 'sig/factorix/cli/commands/cache/stat.rbs', line 10 def logger @logger end |
Instance Method Details
#call(json:) ⇒ void
This method returns an undefined value.
Execute the cache stat command
41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/factorix/cli/commands/cache/stat.rb', line 41 def call(json:, **) logger.debug("Collecting cache statistics") cache_names = Factorix.config.cache.values.keys stats = cache_names.to_h {|name| [name, collect_stats(name)] } if json out.puts JSON.pretty_generate(stats) else output_text(stats) end end |