pluswerk/cache-automation

This package is abandoned and no longer maintained. The author suggests using the andersundsehr/cache-automation package instead.

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

2.0.1 2023-07-20 08:26 UTC

README

.
.
.
.
Use andersundsehr/cache-automation instead
.
.
.
.
.
.
.

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 up to TYPO3 9

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