You are here

public function FastlyCommands::purgeKeys in Fastly 8.3

Purge cache by key.

@command fastly:purge:key @aliases fpkey

Parameters

string $keys: A comma-separated list of keys to purge.

File

src/Commands/FastlyCommands.php, line 84

Class

FastlyCommands
Provides drush commands for Fastly.

Namespace

Drupal\fastly\Commands

Code

public function purgeKeys($keys = '') {
  if (empty($keys)) {
    return;
  }
  $keys = explode(',', $keys);
  $hashes = $this->cacheTagsHash
    ->cacheTagsToHashes($keys);
  if ($this->api
    ->purgeKeys($hashes)) {
    $this
      ->output()
      ->writeln("<info>Successfully purged key(s) on Fastly.</info>");
  }
  else {
    $this
      ->output()
      ->writeln("<error>Unable to purged key(s) on Fastly.</error>");
  }
}