Skip to main content
KadiCache
Browse 37 Docs Guides & Search

Complete WP-CLI Command Reference (Cache, Preload, Object Cache, DB & MCP)

Automate cache purges, URL diagnostics, bounded sitemap preloads, 7-driver object cache probes, dry-run database cleanups, and MCP token/checkpoint operations from SSH or CI/CD.

Cli/CacheCli.phpPreload/PreloadCli.phpCli/ObjectCacheCli.phpCli/DatabaseCli.phpCli/McpCli.php
WP Admin -> KadiCache -> Dashboard (Dark)
MODULE 06 · 2X RETINA
Dark-theme workspace engineered with persisted pre-paint theme state and zero FOUC.2880×1840 WebP
Quick Summary · 30-Second Operational SpecSource-Verified Guide
WP Admin Path
SSH / CI Terminal -> wp kadicache <command>
Expected Outcome
8 Command Families · Deterministic --format=json · Multisite --network Aware
Key Marker / Engine
CacheCli.php | PreloadCli.php | ObjectCacheCli.php | DatabaseCli.php | McpCli.php
  • Provides 8 complete wp kadicache command families (status, purge, repair, diagnose, preload, object-cache, db, and mcp) sharing the exact same safety guards as WP Admin.
  • Every command supports --format=json with deterministic exit codes (0 on success, 1 via WP_CLI::halt(1) on error)—built for GitHub Actions, GitLab CI, Deployer, Trellis, and cron scripts.
  • Supports WordPress Multisite (--url=<subsite> and --network flags on status, purge --network --all, repair --network, and object-cache flush --blog=<id>).
  • Enforces capability checks (manage_options / manage_network_options) when --user is passed and checks cache directory ownership (cache_directory_ownership) before mutating local storage.

Automating KadiCache in SSH, Composer/Bedrock & CI/CD Pipelines#

DevOps engineers, managed-hosting SREs, and agencies deploying WordPress updates via GitHub Actions or Deployer need deterministic CLI commands that never trigger HTML redirects, never swallow failures with exit code 0, and never corrupt file ownership when invoked under the wrong Linux user.

KadiCache registers all CLI commands inside Plugin.php across five dedicated classes (CacheCli.php, PreloadCli.php, ObjectCacheCli.php, DatabaseCli.php, and McpCli.php). Every command outputs human-friendly tables by default and machine-parseable JSON when --format=json is passed.

FIG 01Every WP-CLI command shares the exact same status, purge, preload, and diagnostic engines shown in WP Admin -> KadiCacheZoom 2x

1. Core Cache Status, Purge, Repair & URL Diagnosis (CacheCli.php)#

Command & FlagsPurpose & Exact Behavior
wp kadicache status [--network] [--page=<n>] [--search=<q>] [--format=json]Reports enabled, owner (local vs host), early_cache readiness, early_reason, disk storage usage, preload queue counts, active integrations (multilingual, cloudflare, varnish, host), visits_24h, and runtime_reasons. With --network, lists Multisite subsites!
wp kadicache purge --all [--format=json]Purges the entire current site across local FileCache, Cloudflare, Varnish, and host bridges (verifying cache_directory_ownership first so root SSH runs never break PHP-FPM permissions!)
wp kadicache purge <url>... [--format=json]Surgically purges one or more same-site URLs (wp kadicache purge https://example.com/ https://example.com/shop/)
wp kadicache purge --network --all [--format=json]Queues a network-wide Multisite purge (NetworkLifecycle::start('purge'))
wp kadicache repair [--network] [--format=json]Re-verifies and repairs wp-content/advanced-cache.php, early-config.php, WP_CACHE, or network routing maps (PostSettings::repairManually())
wp kadicache diagnose <url> [--format=json]Runs the full PageDiagnostic inspector on a same-site URL—returning Desktop & Mobile cache states, anonymous loopback HTTP headers, cookies, and script advice!
FIG 02Running wp kadicache diagnose <url> --format=json returns the exact same PageDiagnostic report in your terminalZoom 2x

2. Sitemap Preload & Warmup Queue Commands (PreloadCli.php)#

BASHControlling Background & Foreground Sitemap Warmup
# Inspect queue counts (queued, warmed, skipped, failed) and lock state
wp kadicache preload status --format=json

# Start, pause, or resume background Action Scheduler warmup
wp kadicache preload start
wp kadicache preload pause
wp kadicache preload resume

# Execute one bounded warmup batch immediately in the current CLI process
wp kadicache preload run --url=https://example.com --format=json

3. Persistent Object Cache & Autoload Bloat Analyzer (ObjectCacheCli.php)#

Command & FlagsPurpose & Exact Behavior
wp kadicache object-cache status [--format=table|json]Displays dropin_state, provider, connected, driver, serializer, compression, prefetch, split_alloptions, and live hit_ratio
wp kadicache object-cache info [--format=table|json]Runs a live backend latency probe (ms) and runs AutoloadAnalyzer::inspect() to list your largest autoloaded wp_options rows by byte size and plugin source!
wp kadicache object-cache enable [--driver=<driver>] [--force-takeover] [--format=json]Probes backend and atomically installs wp-content/object-cache.php (driver: auto, relay, phpredis, redis-socket, memcached, apcu, sqlite, file)
wp kadicache object-cache flush [--blog=<id>]Performs an O(1) epoch flush—or flushes only a single Multisite subsite (--blog=3) without evicting sibling sites!
wp kadicache object-cache disableSafely removes wp-content/object-cache.php (only if owned by KadiCache)

4. Safe Database Cleanup & Dry-Run Inspection (DatabaseCli.php)#

BASHInspecting & Cleaning Database Bloat Safely
# Show candidate counts across all 8 categories without deleting anything
wp kadicache db status --format=table

# Preview exact counts for specific categories (--dry-run queues zero deletions)
wp kadicache db clean --items=revisions,auto_drafts,trash_posts,trash_comments,spam_comments,transients,actions,orphans --dry-run

# Queue bounded background cleanup using saved selection or explicit --items
wp kadicache db clean --items=revisions,transients,actions --format=json

5. AI MCP Token, Audit & Checkpoint Commands (McpCli.php)#

BASHManaging OAuth 2.1 Grants, Scoped Tokens & Rollbacks via CLI
# Show MCP endpoint URL, HTTPS readiness, token count, and checkpoint count
wp kadicache mcp status --format=json

# Mint a scoped SHA-256 token expiring in 30 days and print Claude CLI snippet
wp kadicache mcp mint --label="CI Deploy Bot" --scopes=read,operate --days=30

# List active tokens & OAuth grants, view audit logs, revoke, or roll back!
wp kadicache mcp tokens --format=table
wp kadicache mcp activity --limit=25
wp kadicache mcp rollback latest
wp kadicache mcp revoke <token_id_or_og_grant_id>
wp kadicache mcp disconnect-all

Production Post-Deploy Hook Example (GitHub Actions / Deployer)#

BASHZero-Downtime Production Release Script (Run as PHP-FPM Web User)
#!/usr/bin/env bash
set -euo pipefail

# Always execute as the web/PHP-FPM user (e.g. www-data) so cache file ownership stays clean
wp kadicache repair --format=json
wp kadicache purge --all --format=json
wp kadicache preload start --format=json
wp kadicache diagnose "$(wp option get home)/" --format=json

Multisite Fleet Maintenance & Cron Automation Examples#

When managing a 40-subsite WordPress Multisite installation or running scheduled nightly verification from system systemd timers / cron:

  • Network-Wide Health Table (--network): Run wp kadicache status --network --page=1 to view a clean ASCII table (blog_id, url, state, enabled, early, updated_at) across your subsites, or pass --format=json to pipe straight into jq / Datadog / Prometheus.
  • Targeted Single-Subsite Object Cache Flush (--blog=<id>): Running wp kadicache object-cache flush --blog=7 bumps only Subsite #7’s cache epoch without evicting cached database queries on the other 39 subsites!
  • Impersonating Specific Admin Roles (--user=<login>): When a deployment script passes --user=editor_jane, CacheCli::authorize() enforces real WordPress capability checks (manage_options on single-site; manage_network_options on --network) so least-privilege automation stays airtight.

Frequently Asked Operational Questions

Do KadiCache WP-CLI commands return non-zero exit codes when an operation fails?
Yes! CacheCli::fail() calls WP_CLI::halt(1) (even in --format=json mode, printing {"success":false,"error":"..."} before halting with exit code 1) so CI/CD pipelines fail fast instead of silently ignoring errors.
How do I target a specific subsite on WordPress Multisite via WP-CLI?
Pass WordPress’s standard --url=https://subsite.example.com global flag for single-subsite operations (status, purge, repair, preload, db, mcp), or pass --network for network-wide status, purge --network --all, and repair --network.
Does wp kadicache purge --all also clear Cloudflare and Varnish?
Yes! CLI purges invoke the exact same Plugin::purgeCurrentSite("api") dispatcher as WP Admin—triggering local FileCache invalidation plus configured Cloudflare, Varnish, and managed-host bridges.
Can I safely test wp kadicache db clean without deleting any database rows?
Yes—pass --dry-run (for example: wp kadicache db clean --items=revisions,transients --dry-run) to inspect exact candidate counts with zero rows deleted.
Why does wp kadicache mcp mint only display the raw token string once?
For security, McpTokenStore hashes every minted token immediately with SHA-256 and never stores plaintext tokens in the WordPress database—so copy the printed token immediately or revoke and mint a fresh one.
Gergis — Lead Systems & Cache Architect
Principal WordPress & Cloud Edge Architect
E-E-A-T Source Verified

Creator of KadiCache’s Early PHP Drop-In, 7-Driver Object Cache Engine, Cloud Remove Unused CSS, and Zero-CLS Lazy Render pipeline.

apps/wordpress-plugin/src/Cli/CacheCli.phpapps/wordpress-plugin/src/Preload/PreloadCli.phpapps/wordpress-plugin/src/Cli/ObjectCacheCli.phpapps/wordpress-plugin/src/Cli/DatabaseCli.phpapps/wordpress-plugin/src/Cli/McpCli.php
Was this engineering guide helpful?