PHP code example of pluswerk / cache-automation

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

    

pluswerk / cache-automation example snippets


\Pluswerk\CacheAutomation\Service\Configuration::getInstance()->addAgentForTables(
    ['tx_news_domain_model_news'], // database table name
    \Pluswerk\CacheAutomation\Agents\SimplePluginAgent::class, // cache agent
    [
        // cache agent configuration
        'pluginKeys' => ['news_pi1'],
    ]
);

\Pluswerk\CacheAutomation\Service\Configuration::getInstance()->addAgentForTables(
    ['tx_news_domain_model_news'],
    \Pluswerk\CacheAutomation\Agents\SimplePluginAgent::class,
    [
        'pluginKeys' => ['news_pi1'],
    ]
);

\Pluswerk\CacheAutomation\Service\Configuration::getInstance()->addAgentForTables(
    ['tx_news_domain_model_news'],
    \Pluswerk\CacheAutomation\Agents\PageRootlineAgent::class,
    [
        'rootPages' => [42, 316],
        'depth' => 99, // optional
        'begin' => 0, // optional
    ]
);

class MyMagicCacheAgent implements \Pluswerk\CacheAutomation\Agents\AgentInterface
{
    public function getExpiredPages(string $table, int $uid, array $agentConfiguration, array $changedFields): array
    {
        // doe some magic here and return all page uid's which caches should be flushed
        return [42, 316];
    }
}