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

Public Member Functions

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

Public Attributes

const FAKED_UNLIMITED_EXPIRE = 2145909600
 
- ‪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

 throwExceptionIfFrontendDoesNotExist ()
 
- ‪Protected Member Functions inherited from ‪TYPO3\CMS\Core\Cache\Backend\AbstractBackend
DateTime calculateExpiryTime ($lifetime=null)
 

Protected Attributes

string $cacheTable
 
string $tagsTable
 
bool $compression = false
 
int $compressionLevel = -1
 
int $maximumLifetime
 
- ‪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 in database tables

Definition at line 29 of file Typo3DatabaseBackend.php.

Member Function Documentation

◆ collectGarbage()

◆ findIdentifiersByTag()

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

Finds and returns all cache entries 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 218 of file Typo3DatabaseBackend.php.

References $GLOBALS, TYPO3\CMS\Core\Database\Connection\PARAM_INT, and TYPO3\CMS\Core\Cache\Backend\Typo3DatabaseBackend\throwExceptionIfFrontendDoesNotExist().

◆ flush()

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

◆ flushByTag()

TYPO3\CMS\Core\Cache\Backend\Typo3DatabaseBackend::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 309 of file Typo3DatabaseBackend.php.

References TYPO3\CMS\Core\Database\Connection\PARAM_STR_ARRAY, and TYPO3\CMS\Core\Cache\Backend\Typo3DatabaseBackend\throwExceptionIfFrontendDoesNotExist().

◆ flushByTags()

TYPO3\CMS\Core\Cache\Backend\Typo3DatabaseBackend::flushByTags ( array  $tags)

Removes all entries tagged by any of the specified tags. Performs the SQL operation as a bulk query for better performance.

Parameters
string[]$tags

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

Definition at line 263 of file Typo3DatabaseBackend.php.

References TYPO3\CMS\Core\Database\Connection\PARAM_STR_ARRAY, and TYPO3\CMS\Core\Cache\Backend\Typo3DatabaseBackend\throwExceptionIfFrontendDoesNotExist().

◆ get()

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

Loads data from a cache file.

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

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

Definition at line 128 of file Typo3DatabaseBackend.php.

References $GLOBALS, TYPO3\CMS\Core\Database\Connection\PARAM_INT, and TYPO3\CMS\Core\Cache\Backend\Typo3DatabaseBackend\throwExceptionIfFrontendDoesNotExist().

◆ getCacheTable()

string TYPO3\CMS\Core\Cache\Backend\Typo3DatabaseBackend::getCacheTable ( )

Returns the table where the cache entries are stored.

Returns
‪string The cache table.

Definition at line 401 of file Typo3DatabaseBackend.php.

References TYPO3\CMS\Core\Cache\Backend\Typo3DatabaseBackend\$cacheTable, and TYPO3\CMS\Core\Cache\Backend\Typo3DatabaseBackend\throwExceptionIfFrontendDoesNotExist().

◆ getTableDefinitions()

string TYPO3\CMS\Core\Cache\Backend\Typo3DatabaseBackend::getTableDefinitions ( )

Calculate needed table definitions for this cache. This helper method is used by install tool and extension manager and is not part of the public API!

Returns
‪string SQL of table definitions

Definition at line 461 of file Typo3DatabaseBackend.php.

References TYPO3\CMS\Core\Utility\ExtensionManagementUtility\extPath().

◆ getTagsTable()

string TYPO3\CMS\Core\Cache\Backend\Typo3DatabaseBackend::getTagsTable ( )

Gets the table where cache tags are stored.

Returns
‪string Name of the table storing tags

Definition at line 412 of file Typo3DatabaseBackend.php.

References TYPO3\CMS\Core\Cache\Backend\Typo3DatabaseBackend\$tagsTable, and TYPO3\CMS\Core\Cache\Backend\Typo3DatabaseBackend\throwExceptionIfFrontendDoesNotExist().

◆ has()

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

Checks if a cache entry with the specified identifier exists.

Parameters
string$entryIdentifier‪Specifies the identifier to check for existence
Returns
‪bool TRUE if such an entry exists, FALSE if not

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

Definition at line 163 of file Typo3DatabaseBackend.php.

References $GLOBALS, TYPO3\CMS\Core\Database\Connection\PARAM_INT, and TYPO3\CMS\Core\Cache\Backend\Typo3DatabaseBackend\throwExceptionIfFrontendDoesNotExist().

◆ remove()

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

Removes all cache entries matching the specified identifier. Usually this only affects one entry.

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 192 of file Typo3DatabaseBackend.php.

References TYPO3\CMS\Core\Database\Connection\PARAM_STR, and TYPO3\CMS\Core\Cache\Backend\Typo3DatabaseBackend\throwExceptionIfFrontendDoesNotExist().

◆ set()

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

Saves data in a cache file.

Parameters
string$entryIdentifier‪An identifier for this specific cache entry
string$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.
InvalidDataException‪if the data to be stored is not a string.

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

Definition at line 78 of file Typo3DatabaseBackend.php.

References TYPO3\CMS\Core\Cache\Backend\AbstractBackend\$defaultLifetime, $GLOBALS, TYPO3\CMS\Core\Cache\Backend\Typo3DatabaseBackend\$maximumLifetime, TYPO3\CMS\Core\Database\Connection\PARAM_LOB, TYPO3\CMS\Core\Database\Connection\PARAM_STR, and TYPO3\CMS\Core\Cache\Backend\Typo3DatabaseBackend\throwExceptionIfFrontendDoesNotExist().

◆ setCache()

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

Set cache frontend instance and calculate data and tags table name

Parameters
FrontendInterface$cache‪The frontend for this backend

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

Definition at line 60 of file Typo3DatabaseBackend.php.

References TYPO3\CMS\Core\Cache\Backend\AbstractBackend\$cache, TYPO3\CMS\Core\Cache\Backend\AbstractBackend\$cacheIdentifier, and $GLOBALS.

◆ setCompression()

TYPO3\CMS\Core\Cache\Backend\Typo3DatabaseBackend::setCompression (   $compression)

Enable data compression

Parameters
bool$compression‪TRUE to enable compression

Definition at line 423 of file Typo3DatabaseBackend.php.

References TYPO3\CMS\Core\Cache\Backend\Typo3DatabaseBackend\$compression.

◆ setCompressionLevel()

TYPO3\CMS\Core\Cache\Backend\Typo3DatabaseBackend::setCompressionLevel (   $compressionLevel)

Set data compression level. If compression is enabled and this is not set, gzcompress default level will be used

Parameters
int$compressionLevel‪-1 to 9: Compression level

Definition at line 435 of file Typo3DatabaseBackend.php.

References TYPO3\CMS\Core\Cache\Backend\Typo3DatabaseBackend\$compressionLevel.

◆ throwExceptionIfFrontendDoesNotExist()

Member Data Documentation

◆ $cacheTable

string TYPO3\CMS\Core\Cache\Backend\Typo3DatabaseBackend::$cacheTable
protected

Name of the cache data table

Definition at line 37 of file Typo3DatabaseBackend.php.

Referenced by TYPO3\CMS\Core\Cache\Backend\Typo3DatabaseBackend\getCacheTable().

◆ $compression

bool TYPO3\CMS\Core\Cache\Backend\Typo3DatabaseBackend::$compression = false
protected

Indicates whether data is compressed or not (requires php zlib)

Definition at line 45 of file Typo3DatabaseBackend.php.

Referenced by TYPO3\CMS\Core\Cache\Backend\Typo3DatabaseBackend\setCompression().

◆ $compressionLevel

int TYPO3\CMS\Core\Cache\Backend\Typo3DatabaseBackend::$compressionLevel = -1
protected

-1 to 9, indicates zlib compression level: -1 = default level 6, 0 = no compression, 9 maximum compression

Definition at line 49 of file Typo3DatabaseBackend.php.

Referenced by TYPO3\CMS\Core\Cache\Backend\Typo3DatabaseBackend\setCompressionLevel().

◆ $maximumLifetime

int TYPO3\CMS\Core\Cache\Backend\Typo3DatabaseBackend::$maximumLifetime
protected

Maximum lifetime to stay with expire field below FAKED_UNLIMITED_LIFETIME

Definition at line 53 of file Typo3DatabaseBackend.php.

Referenced by TYPO3\CMS\Core\Cache\Backend\Typo3DatabaseBackend\set().

◆ $tagsTable

string TYPO3\CMS\Core\Cache\Backend\Typo3DatabaseBackend::$tagsTable
protected

Name of the cache tags table

Definition at line 41 of file Typo3DatabaseBackend.php.

Referenced by TYPO3\CMS\Core\Cache\Backend\Typo3DatabaseBackend\getTagsTable().

◆ FAKED_UNLIMITED_EXPIRE

const TYPO3\CMS\Core\Cache\Backend\Typo3DatabaseBackend::FAKED_UNLIMITED_EXPIRE = 2145909600

Definition at line 34 of file Typo3DatabaseBackend.php.