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

Inherits:
Base
  • Object
show all
Includes:
Formatting
Defined in:
lib/factorix/cli/commands/cache/evict.rb

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 Method Summary collapse

Methods included from Formatting

#format_duration, #format_size

Methods inherited from Base

backup_support!, confirmable!, inherited, require_game_stopped!

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



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