xima/t3api-cache

There is no license information available for the latest version (dev-main) of this package.

Adds caching to the t3api extension.

Installs: 4

Dependents: 0

Suggesters: 0

Security: 0

Stars: 1

Watchers: 3

Forks: 0

Open Issues: 0

Type:typo3-cms-extension

dev-main 2025-02-20 17:11 UTC

This package is auto-updated.

Last update: 2025-02-20 17:11:45 UTC


README

This extension provides a simple cache for the API response of the TYPO3 extension t3api.

Installation

Install the extension via composer:

composer require xima/t3api-cache

Usage

The extension provides a new Annotation @ApiCache which can be used in your ApiResource class to active caching for the specific resource:

<?php

use Xima\T3ApiCache\Annotation\ApiCache;

/**
* @ApiResource(
*     collectionOperations={
*         "get": {
*             "path": "/news"
*         }
*     }
* )
* @ApiCache
*/
class News extends AbstractEntity
{
}

Configuration

There a two configuration options available:

parametersToIgnore

This option allows you to prevent caching of the response for specific query parameters. This can be useful if you have e.g. a search parameter which should not be cached, since it is too individual.

<?php

use SourceBroker\T3api\Annotation\ApiFilter;
use SourceBroker\T3api\Filter\SearchFilter;
use Xima\T3ApiCache\Annotation\ApiCache;

/**
* ...
* @ApiFilter(SearchFilter::class, properties={"title": "partial", "teaser": "partial"}, arguments={"parameterName": "search"})
* @ApiCache(parametersToIgnore={"search"})
*/
class ExampleResource extends AbstractEntity
{
}

lifetime

The lifetime of the cache entry in seconds. Default is 86400 (1 day).

<?php

use Xima\T3ApiCache\Annotation\ApiCache;

/**
* ...
* @ApiCache(lifetime=3600) // Cache lifetime set to 1 hour
*/
class ExampleResource extends AbstractEntity
{
}