pluswerk/cache-automation

+Pluswerk TYPO3 extension: Cache Automation - This TYPO3 extension clear caches automated in the right moment.

Installs: 2 719

Dependents: 0

Suggesters: 0

Stars: 3

Watchers: 6

Forks: 3

Open Issues: 3

Type:typo3-cms-extension

1.1.3 2018-12-04 08:54 UTC

README

Packagist Release Travis GitHub License Code Climate

TYPO3 Extension: Cache Automation

This TYPO3 extension clear caches automated in the right moment. This happens by some magic configuration of your extension.

Example:

With this TYPO3 extension you can cache for example an extbase "list and show" plugin. If a database record is updated the cache of all pages containing this plugin will be flushed.

You can write your own magic cache agent.

Requires TYPO3 8.7

Issue tracking: GitHub: TYPO3 Cache Automation

Packagist: pluswerk/cache-automation

Installation

  1. Install the TYPO3 extension via composer

Composer installation:

composer require pluswerk/cache-automation

Configuration

Configure cache agent

Configure a cache agent for your extension in your ext_localconf.php.

A cache agent is triggered, if a database record of the given tables has changed.

Example:

\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'],
    ]
);

Available cache agents

SimplePluginAgent

This agent flush the cache of all pages which have a content element with the given plugin keys.

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

PageRootlineAgent

This agent flush the cache of all pages which are in the TYPO3 "rootline" of the given pages.

\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
    ]
);

Use your own cache agent

You can simply use your own cache agent. It has to implement \Pluswerk\CacheAutomation\Agents\AgentInterface:

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];
    }
}