Class: Factorix::CLI::Commands::Cache::Evict

Inherits:
Base show all
Includes:
Formatting
Defined in:
lib/factorix/cli/commands/cache/evict.rb,
sig/factorix/cli/commands/cache/evict.rbs

Overview

Evict cache entries

This command removes cache entries based on the specified criteria. At least one of --all, --expired, or --older-than must be specified.

Examples:

$ factorix cache evict --expired
$ factorix cache evict api --all
$ factorix cache evict download --older-than 7d

Instance Attribute Summary collapse

Instance Method Summary collapse

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/evict.rbs', line 10

def logger
  @logger
end

Instance Method Details

#call(caches: nil, all: false, expired: false, older_than: nil) ⇒ void

This method returns an undefined value.

Execute the cache evict command

Parameters:

  • caches (Array<String>, nil) (defaults to: nil) —

    cache names to evict

  • all (Boolean) (defaults to: false) —

    remove all entries

  • expired (Boolean) (defaults to: false) —

    remove expired entries only

  • older_than (String, nil) (defaults to: nil) —

    remove entries older than this age

  • caches: (Array[String], nil) (defaults to: nil)
  • all: (Boolean) (defaults to: false)
  • expired: (Boolean) (defaults to: false)
  • older_than: (String, nil) (defaults to: nil)


48
49
50
51
52
53
54
55
56
57
# File 'lib/factorix/cli/commands/cache/evict.rb', line 48

def call(caches: nil, all: false, expired: false, older_than: nil, **)
  validate_options!(all, expired, older_than)

  @older_than_seconds = parse_age(older_than) if older_than

  cache_names = resolve_cache_names(caches)
  results = cache_names.to_h {|name| [name, evict_cache(name, all:, expired:)] }

  output_results(results)
end