PHP code example of padosoft / laravel-super-cache-invalidate

1. Go to this page and download the library: Download padosoft/laravel-super-cache-invalidate library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

padosoft / laravel-super-cache-invalidate example snippets


return [
    'total_shards' => 10,
    'invalidation_window' => 60,
    'processing_limit' => 10000,
    'tag_batch_size' => 100,
    'lock_timeout' => 600,
    'key_invalidation_callback' => null,
    'tag_invalidation_callback' => null,
    'default_connection_name' => null,
];

use Padosoft\SuperCacheInvalidate\Helpers\SuperCacheInvalidationHelper;

$helper = app(Padosoft\SuperCacheInvalidate\Helpers\SuperCacheInvalidationHelper::class);

// Invalidate a tag
$helper->insertInvalidationEvent('tag', 'category:sport', 'cache', 'Product updated in category sport');

// Invalidate a key
$helper->insertInvalidationEvent('key', 'cache_key_xyz', 'fullpage-cache', 'Specific cache key invalidated');

// Invalidate a key with associated tags
// In this example, when the event for article_ID:7 is processed,
// it will also consider plp:sport during invalidation.
// If plp:sport is within its invalidation window, the invalidation of article_ID:7
// will be deferred to ensure consistency.
$helper->insertInvalidationEvent(
    'tag',
    'article_ID:7',
    'fullpage-cache',
    'Article 7 removed from sale',
    0,
    0,
    [
        ['type' => 'tag', 'identifier' => 'plp:sport', 'connection_name' => 'cache']
    ]
);

$schedule->command('supercache:process-invalidation --shard=0 --priority=0')->everyMinute();
bash
php artisan vendor:publish --provider="Padosoft\SuperCacheInvalidate\SuperCacheInvalidateServiceProvider"
bash
php artisan migrate
bash
php artisan supercache:process-invalidation --shard=0 --priority=0 --connection_name=cache