PHP code example of vectorial1024 / laravel-cache-evict

1. Go to this page and download the library: Download vectorial1024/laravel-cache-evict 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/ */

    

vectorial1024 / laravel-cache-evict example snippets


use Vectorial1024\LaravelCacheEvict\CacheEvictCommand;

// note: because this command may have long running time, it is strongly recommended to run this command in the background
// this avoids accidentally delaying other scheduled tasks

// evicts the default cache in your Laravel app
Schedule::command(CacheEvictCommand::class)->daily()->runInBackground();

// you may also specify the cache to clear; e.g. the file cache defined in cache.php:
Schedule::command(CacheEvictCommand::class, ['target' => 'file'])->daily()->runInBackground();

[
    'stores' => [
        'local_store' => [
            'driver' => 'file',
            // other config...
        ],

        'another_store' => [
            'driver' => 'file',
            // other config...
        ],
    ],
]

public function boot()
{
    // register a handler for a specific cache driver
    // YourEvictStrategy extends Vectorial1024\LaravelCacheEvict\AbstractEvictStrategy
    CacheEvictStrategies::registerDriverStrategy('your_driver_name', YourEvictStrategy::class);

    // or, register that a specific cache driver should not be handled because it has its own handler already
    CacheEvictStrategies::registerDriverRefusedBecauseFeatureExists('self_managed_driver_name');
}
sh
php artisan cache:evict local_store