Files
rspade_system/app/RSpade/Commands/Rsx/Ssr_Fpc_Reset_Command.php
root f6fac6c4bc Fix bin/publish: copy docs.dist from project root
Fix bin/publish: use correct .env path for rspade_system
Fix bin/publish script: prevent grep exit code 1 from terminating script

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-21 02:08:33 +00:00

89 lines
2.3 KiB
PHP
Executable File

<?php
/**
* CODING CONVENTION:
* This file follows the coding convention where variable_names and function_names
* use snake_case (underscore_wherever_possible).
*/
namespace App\RSpade\Commands\Rsx;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Redis;
/**
* RSX SSR Full Page Cache (FPC) Reset Command
* ============================================
*
* PURPOSE:
* Clears all SSR FPC caches from Redis. This is useful when you want to force
* regeneration of all static pages, such as after a major content update or
* when troubleshooting caching issues.
*
* HOW IT WORKS:
* 1. Scans Redis for all keys matching the pattern: ssr_fpc:*
* 2. Deletes all matching keys
* 3. Reports count of cleared cache entries
*
* USAGE:
* php artisan rsx:ssr_fpc:reset
*
* WHEN TO USE:
* - After major content updates across the site
* - When troubleshooting caching issues
* - Before deployment to ensure fresh cache generation
* - When the build_key has changed (auto-invalidation should handle this)
*
* SECURITY:
* - Available in all environments (local, staging, production)
* - Safe to run - only affects SSR FPC caches, not other Redis data
* - Does NOT affect:
* - Application caches
* - Session data
* - Queue jobs
* - Other Redis namespaced data
*/
class Ssr_Fpc_Reset_Command extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'rsx:ssr_fpc:reset';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Clear all SSR Full Page Cache entries from Redis';
/**
* Execute the console command.
*/
public function handle()
{
$this->info('Clearing SSR FPC caches...');
try {
// Get all keys matching the SSR FPC pattern
$keys = Redis::keys('ssr_fpc:*');
if (empty($keys)) {
$this->info('No SSR FPC cache entries found.');
return 0;
}
// Delete all FPC cache keys
$deleted = Redis::del($keys);
$this->info("✅ Cleared {$deleted} SSR FPC cache entries");
return 0;
} catch (\Exception $e) {
$this->error('❌ Failed to clear SSR FPC caches: ' . $e->getMessage());
return 1;
}
}
}