/** * Flush proxy caches. * * ## OPTIONS * * [--cache=<url>] * : The name of the person to greet. * * [--format=<format>] * : Accepted values: csv, json. Default: csv * * ## EXAMPLES * * wp nginx list --format=json * wp nginx flush * wp nginx flush --cache=http://example.com/archives/10 * * @synopsis [--cache=<url>] * @subcommand flush */ function flush($args, $assoc_args) { global $nginxchampuru; if (isset($assoc_args['cache']) && $assoc_args['cache']) { $id = url_to_postid($assoc_args['cache']); if ($id) { NginxChampuru_FlushCache::flush_by_post($id); WP_CLI::success("Proxy caches are flushed on " . $assoc_args['cache']); exit; } else { WP_CLI::error('Cache url is not found.'); exit; } } else { $nginxchampuru->transientExec("flush_cache", 'all', 0); WP_CLI::success("All proxy caches are flushed."); exit; } }