‪TYPO3CMS  ‪main
TYPO3\CMS\Core\Cache\Backend\ApcuBackend Class Reference
Inheritance diagram for TYPO3\CMS\Core\Cache\Backend\ApcuBackend:
TYPO3\CMS\Core\Cache\Backend\AbstractBackend TYPO3\CMS\Core\Cache\Backend\TaggableBackendInterface TYPO3\CMS\Core\Cache\Backend\TransientBackendInterface TYPO3\CMS\Core\Cache\Backend\BackendInterface TYPO3\CMS\Core\Cache\Backend\BackendInterface TYPO3\CMS\Core\Cache\Backend\BackendInterface

Public Member Functions

 __construct ($context, array $options=[])
 
 setCache (FrontendInterface $cache)
 
 set ($entryIdentifier, $data, array $tags=[], $lifetime=null)
 
mixed get ($entryIdentifier)
 
bool has ($entryIdentifier)
 
bool remove ($entryIdentifier)
 
array findIdentifiersByTag ($tag)
 
 flush ()
 
 flushByTag ($tag)
 
 collectGarbage ()
 
- ‪Public Member Functions inherited from ‪TYPO3\CMS\Core\Cache\Backend\AbstractBackend
 setDefaultLifetime ($defaultLifetime)
 
 flushByTags (array $tags)
 
- ‪Public Member Functions inherited from ‪TYPO3\CMS\Core\Cache\Backend\TaggableBackendInterface
 flushByTags (array $tags)
 

Private Member Functions

 addIdentifierToTags (string $entryIdentifier, array $tags)
 
 removeIdentifierFromAllTags (string $entryIdentifier)
 
 findTagsByIdentifier (string $identifier)
 

Private Attributes

string $identifierPrefix = ''
 

Additional Inherited Members

- ‪Public Attributes inherited from ‪TYPO3\CMS\Core\Cache\Backend\AbstractBackend
const DATETIME_EXPIRYTIME_UNLIMITED = '9999-12-31T23:59:59+0000'
 
const UNLIMITED_LIFETIME = 0
 
- ‪Protected Member Functions inherited from ‪TYPO3\CMS\Core\Cache\Backend\AbstractBackend
DateTime calculateExpiryTime ($lifetime=null)
 
- ‪Protected Attributes inherited from ‪TYPO3\CMS\Core\Cache\Backend\AbstractBackend
FrontendInterface $cache
 
string $cacheIdentifier
 
string $context
 
int $defaultLifetime = 3600
 

Detailed Description

A caching backend which stores cache entries by using APCu.

The APCu backend is not very good with tagging and scales O(2n) with the number of tags. Do not use this backend if the data to be cached has many tags!

This backend uses the following types of keys:

  • ‪tag_xxx xxx is tag name, value is array of associated identifiers identifier. This is "forward" tag index. It is mainly used for obtaining content by tag (get identifier by tag -> get content by identifier)
  • ‪ident_xxx xxx is identifier, value is array of associated tags. This is "reverse" tag index. It provides quick access for all tags associated with this identifier and used when removing the identifier

Each key is prepended with a prefix. The prefix makes sure keys from the different installations do not conflict. By default, prefix consists from two parts separated by underscore character and ends in yet another underscore character:

  • ‪"TYPO3"
  • ‪Hash of path to TYPO3 and user running TYPO3

Definition at line 44 of file ApcuBackend.php.

Constructor & Destructor Documentation

◆ __construct()

TYPO3\CMS\Core\Cache\Backend\ApcuBackend::__construct (   $context,
array  $options = [] 
)

Constructs this backend

Parameters
string$context‪Unused, for backward compatibility only
array$optionsConfiguration options - unused here
Exceptions
Exception

Reimplemented from TYPO3\CMS\Core\Cache\Backend\AbstractBackend.

Definition at line 58 of file ApcuBackend.php.

References TYPO3\CMS\Core\Cache\Backend\AbstractBackend\$context.

Member Function Documentation

◆ addIdentifierToTags()

TYPO3\CMS\Core\Cache\Backend\ApcuBackend::addIdentifierToTags ( string  $entryIdentifier,
array  $tags 
)
private

◆ collectGarbage()

TYPO3\CMS\Core\Cache\Backend\ApcuBackend::collectGarbage ( )

Does garbage collection

Implements TYPO3\CMS\Core\Cache\Backend\BackendInterface.

Definition at line 253 of file ApcuBackend.php.

◆ findIdentifiersByTag()

array TYPO3\CMS\Core\Cache\Backend\ApcuBackend::findIdentifiersByTag (   $tag)

Finds and returns all cache entry identifiers which are tagged by the specified tag.

Parameters
string$tag‪The tag to search for
Returns
‪array An array with identifiers of all matching entries. An empty array if no entries matched

Implements TYPO3\CMS\Core\Cache\Backend\TaggableBackendInterface.

Definition at line 149 of file ApcuBackend.php.

Referenced by TYPO3\CMS\Core\Cache\Backend\ApcuBackend\addIdentifierToTags(), TYPO3\CMS\Core\Cache\Backend\ApcuBackend\flushByTag(), and TYPO3\CMS\Core\Cache\Backend\ApcuBackend\removeIdentifierFromAllTags().

◆ findTagsByIdentifier()

TYPO3\CMS\Core\Cache\Backend\ApcuBackend::findTagsByIdentifier ( string  $identifier)
private

Finds all tags for the given identifier. This function uses reverse tag index to search for tags.

Definition at line 246 of file ApcuBackend.php.

References TYPO3\CMS\Webhooks\Message\$identifier.

Referenced by TYPO3\CMS\Core\Cache\Backend\ApcuBackend\addIdentifierToTags(), and TYPO3\CMS\Core\Cache\Backend\ApcuBackend\removeIdentifierFromAllTags().

◆ flush()

TYPO3\CMS\Core\Cache\Backend\ApcuBackend::flush ( )

Removes all cache entries of this cache.

Exceptions
Exception

Implements TYPO3\CMS\Core\Cache\Backend\BackendInterface.

Definition at line 164 of file ApcuBackend.php.

◆ flushByTag()

TYPO3\CMS\Core\Cache\Backend\ApcuBackend::flushByTag (   $tag)

Removes all cache entries of this cache which are tagged by the specified tag.

Parameters
string$tag‪The tag the entries must have

Implements TYPO3\CMS\Core\Cache\Backend\TaggableBackendInterface.

Definition at line 177 of file ApcuBackend.php.

References TYPO3\CMS\Webhooks\Message\$identifier, and TYPO3\CMS\Core\Cache\Backend\ApcuBackend\findIdentifiersByTag().

◆ get()

mixed TYPO3\CMS\Core\Cache\Backend\ApcuBackend::get (   $entryIdentifier)

Loads data from the cache.

Parameters
string$entryIdentifier‪An identifier which describes the cache entry to load
Returns
‪mixed The cache entry's content as a string or FALSE if the cache entry could not be loaded

Implements TYPO3\CMS\Core\Cache\Backend\BackendInterface.

Definition at line 108 of file ApcuBackend.php.

◆ has()

bool TYPO3\CMS\Core\Cache\Backend\ApcuBackend::has (   $entryIdentifier)

Checks if a cache entry with the specified identifier exists.

Parameters
string$entryIdentifier‪An identifier specifying the cache entry
Returns
‪bool TRUE if such an entry exists, FALSE if not

Implements TYPO3\CMS\Core\Cache\Backend\BackendInterface.

Definition at line 121 of file ApcuBackend.php.

◆ remove()

bool TYPO3\CMS\Core\Cache\Backend\ApcuBackend::remove (   $entryIdentifier)

Removes all cache entries matching the specified identifier. Usually this only affects one entry but if - for what reason ever - old entries for the identifier still exist, they are removed as well.

Parameters
string$entryIdentifier‪Specifies the cache entry to remove
Returns
‪bool TRUE if (at least) an entry could be removed or FALSE if no entry was found

Implements TYPO3\CMS\Core\Cache\Backend\BackendInterface.

Definition at line 136 of file ApcuBackend.php.

References TYPO3\CMS\Core\Cache\Backend\ApcuBackend\removeIdentifierFromAllTags().

◆ removeIdentifierFromAllTags()

TYPO3\CMS\Core\Cache\Backend\ApcuBackend::removeIdentifierFromAllTags ( string  $entryIdentifier)
private

◆ set()

TYPO3\CMS\Core\Cache\Backend\ApcuBackend::set (   $entryIdentifier,
  $data,
array  $tags = [],
  $lifetime = null 
)

Saves data in the cache.

Parameters
string$entryIdentifier‪An identifier for this specific cache entry
mixed$data‪The data to be stored
array$tags‪Tags to associate with this cache entry
int$lifetime‪Lifetime of this cache entry in seconds. If NULL is specified, the default lifetime is used. "0" means unlimited lifetime.
Exceptions
Exception‪if no cache frontend has been set.

Implements TYPO3\CMS\Core\Cache\Backend\BackendInterface.

Definition at line 87 of file ApcuBackend.php.

References TYPO3\CMS\Core\Cache\Backend\AbstractBackend\$defaultLifetime, TYPO3\CMS\Core\Cache\Backend\ApcuBackend\addIdentifierToTags(), and TYPO3\CMS\Core\Cache\Backend\ApcuBackend\removeIdentifierFromAllTags().

◆ setCache()

TYPO3\CMS\Core\Cache\Backend\ApcuBackend::setCache ( FrontendInterface  $cache)

Member Data Documentation

◆ $identifierPrefix

string TYPO3\CMS\Core\Cache\Backend\ApcuBackend::$identifierPrefix = ''
private

A prefix to separate stored data from other data possible stored in the APC.

Definition at line 49 of file ApcuBackend.php.