‪TYPO3CMS  11.5
TYPO3\CMS\Core\Cache\Backend\SimpleFileBackend Class Reference
Inheritance diagram for TYPO3\CMS\Core\Cache\Backend\SimpleFileBackend:
TYPO3\CMS\Core\Cache\Backend\AbstractBackend TYPO3\CMS\Core\Cache\Backend\PhpCapableBackendInterface TYPO3\CMS\Core\Cache\Backend\BackendInterface TYPO3\CMS\Core\Cache\Backend\BackendInterface TYPO3\CMS\Core\Cache\Backend\FileBackend TYPO3\CMS\Core\DependencyInjection\Cache\ContainerBackend

Public Member Functions

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

Public Attributes

const SEPARATOR = '^'
 
const EXPIRYTIME_FORMAT = 'YmdHis'
 
const EXPIRYTIME_LENGTH = 14
 
const DATASIZE_DIGITS = 10
 
- ‪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

 createFinalCacheDirectory ($finalCacheDirectory)
 
bool isCacheFileExpired ($cacheEntryPathAndFilename)
 
mixed findCacheFilesByIdentifier ($entryIdentifier)
 
- ‪Protected Member Functions inherited from ‪TYPO3\CMS\Core\Cache\Backend\AbstractBackend
DateTime calculateExpiryTime ($lifetime=null)
 

Protected Attributes

string $cacheDirectory = ''
 
string $temporaryCacheDirectory = ''
 
string $cacheEntryFileExtension = ''
 
array $cacheEntryIdentifiers = array( )
 
bool $frozen = false
 
- ‪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 files, but does not support or care about expiry times and tags.

Definition at line 32 of file SimpleFileBackend.php.

Member Function Documentation

◆ collectGarbage()

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

Not necessary

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

Reimplemented in TYPO3\CMS\Core\Cache\Backend\FileBackend.

Definition at line 332 of file SimpleFileBackend.php.

◆ createFinalCacheDirectory()

TYPO3\CMS\Core\Cache\Backend\SimpleFileBackend::createFinalCacheDirectory (   $finalCacheDirectory)
protected

Create the final cache directory if it does not exist.

Parameters
string$finalCacheDirectory‪Absolute path to final cache directory
Exceptions
Exception‪If directory is not writable after creation

Definition at line 179 of file SimpleFileBackend.php.

References TYPO3\CMS\Core\Utility\GeneralUtility\mkdir_deep().

Referenced by TYPO3\CMS\Core\Cache\Backend\SimpleFileBackend\setCache().

◆ findCacheFilesByIdentifier()

mixed TYPO3\CMS\Core\Cache\Backend\SimpleFileBackend::findCacheFilesByIdentifier (   $entryIdentifier)
protected

Tries to find the cache entry for the specified identifier.

Parameters
string$entryIdentifier‪The cache entry identifier
Returns
‪mixed The file names (including path) as an array if one or more entries could be found, otherwise FALSE

Reimplemented in TYPO3\CMS\Core\Cache\Backend\FileBackend.

Definition at line 340 of file SimpleFileBackend.php.

References TYPO3\CMS\Core\Cache\Backend\SimpleFileBackend\$cacheEntryFileExtension.

◆ flush()

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

Removes all cache entries of this cache. Flushes a directory by first moving to a temporary resource, and then triggering the remove process. This way directories can be flushed faster to prevent race conditions on concurrent processes accessing the same directory.

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

Reimplemented in TYPO3\CMS\Core\Cache\Backend\FileBackend, and TYPO3\CMS\Core\DependencyInjection\Cache\ContainerBackend.

Definition at line 299 of file SimpleFileBackend.php.

References TYPO3\CMS\Core\Cache\Backend\SimpleFileBackend\$cacheDirectory, TYPO3\CMS\Core\Utility\StringUtility\getUniqueId(), TYPO3\CMS\Core\Utility\GeneralUtility\mkdir(), and TYPO3\CMS\Core\Utility\GeneralUtility\rmdir().

◆ get()

mixed TYPO3\CMS\Core\Cache\Backend\SimpleFileBackend::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 content as a string or FALSE if the cache entry could not be loaded
Exceptions

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

Reimplemented in TYPO3\CMS\Core\Cache\Backend\FileBackend.

Definition at line 243 of file SimpleFileBackend.php.

References TYPO3\CMS\Core\Cache\Backend\SimpleFileBackend\$cacheEntryFileExtension, and TYPO3\CMS\Core\Utility\PathUtility\basename().

◆ getCacheDirectory()

string TYPO3\CMS\Core\Cache\Backend\SimpleFileBackend::getCacheDirectory ( )

Returns the directory where the cache files are stored

Returns
‪string Full path of the cache directory

Definition at line 196 of file SimpleFileBackend.php.

References TYPO3\CMS\Core\Cache\Backend\SimpleFileBackend\$cacheDirectory.

◆ has()

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

Checks if a cache entry with the specified identifier exists.

Parameters
string$entryIdentifier
Returns
‪bool TRUE if such an entry exists, FALSE if not
Exceptions

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

Reimplemented in TYPO3\CMS\Core\Cache\Backend\FileBackend.

Definition at line 262 of file SimpleFileBackend.php.

References TYPO3\CMS\Core\Utility\PathUtility\basename().

◆ isCacheFileExpired()

bool TYPO3\CMS\Core\Cache\Backend\SimpleFileBackend::isCacheFileExpired (   $cacheEntryPathAndFilename)
protected

Checks if the given cache entry files are still valid or if their lifetime has exceeded.

Parameters
string$cacheEntryPathAndFilename
Returns
‪bool

Reimplemented in TYPO3\CMS\Core\Cache\Backend\FileBackend.

Definition at line 324 of file SimpleFileBackend.php.

◆ remove()

bool TYPO3\CMS\Core\Cache\Backend\SimpleFileBackend::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
Exceptions

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

Reimplemented in TYPO3\CMS\Core\Cache\Backend\FileBackend.

Definition at line 278 of file SimpleFileBackend.php.

References TYPO3\CMS\Core\Cache\Backend\SimpleFileBackend\$cacheEntryFileExtension, and TYPO3\CMS\Core\Utility\PathUtility\basename().

◆ requireOnce()

mixed TYPO3\CMS\Core\Cache\Backend\SimpleFileBackend::requireOnce (   $entryIdentifier)

Loads PHP code from the cache and require_onces it right away.

Parameters
string$entryIdentifier‪An identifier which describes the cache entry to load
Returns
‪mixed Potential return value from the include operation
Exceptions

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

Reimplemented in TYPO3\CMS\Core\Cache\Backend\FileBackend.

Definition at line 353 of file SimpleFileBackend.php.

References TYPO3\CMS\Core\Cache\Backend\SimpleFileBackend\$cacheEntryFileExtension, and TYPO3\CMS\Core\Utility\PathUtility\basename().

◆ set()

TYPO3\CMS\Core\Cache\Backend\SimpleFileBackend::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‪This cache backend does not support life times
Exceptions
Exception‪if the directory does not exist or is not writable or exceeds the maximum allowed path length, or if no cache frontend has been set.
InvalidDataException‪if the data to bes stored is not a string.

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

Reimplemented in TYPO3\CMS\Core\Cache\Backend\FileBackend.

Definition at line 212 of file SimpleFileBackend.php.

References TYPO3\CMS\Core\Cache\Backend\SimpleFileBackend\$cacheEntryFileExtension, TYPO3\CMS\Core\Utility\PathUtility\basename(), TYPO3\CMS\Core\Utility\GeneralUtility\fixPermissions(), and TYPO3\CMS\Core\Utility\StringUtility\getUniqueId().

◆ setCache()

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

Sets a reference to the cache frontend which uses this backend and initializes the default cache directory.

Parameters
FrontendInterface$cache‪The cache frontend
Exceptions
Exception

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

Reimplemented in TYPO3\CMS\Core\Cache\Backend\FileBackend.

Definition at line 74 of file SimpleFileBackend.php.

References TYPO3\CMS\Core\Cache\Backend\AbstractBackend\$cache, TYPO3\CMS\Core\Cache\Backend\SimpleFileBackend\$temporaryCacheDirectory, TYPO3\CMS\Core\Cache\Backend\SimpleFileBackend\createFinalCacheDirectory(), and TYPO3\CMS\Core\Core\Environment\getVarPath().

◆ setCacheDirectory()

TYPO3\CMS\Core\Cache\Backend\SimpleFileBackend::setCacheDirectory (   $cacheDirectory)

Sets the directory where the cache files are stored. By default it is assumed that the directory is below TYPO3's Project Path. However, an absolute path can be selected, too.

This method enables to use a cache path outside of TYPO3's Project Path. The final cache path is checked and created in createFinalCacheDirectory(), called by setCache() method, which is done after the cacheDirectory option was handled.

Parameters
string$cacheDirectory‪The cache base directory. If a relative path
Exceptions
Exception‪if the directory is not within allowed

Definition at line 110 of file SimpleFileBackend.php.

References TYPO3\CMS\Core\Cache\Backend\SimpleFileBackend\$cacheDirectory, TYPO3\CMS\Core\Core\Environment\getProjectPath(), TYPO3\CMS\Core\Utility\PathUtility\hasProtocolAndScheme(), and TYPO3\CMS\Core\Core\Environment\isWindows().

Member Data Documentation

◆ $cacheDirectory

string TYPO3\CMS\Core\Cache\Backend\SimpleFileBackend::$cacheDirectory = ''
protected

◆ $cacheEntryFileExtension

◆ $cacheEntryIdentifiers

array TYPO3\CMS\Core\Cache\Backend\SimpleFileBackend::$cacheEntryIdentifiers = array( )
protected

Definition at line 61 of file SimpleFileBackend.php.

◆ $frozen

bool TYPO3\CMS\Core\Cache\Backend\SimpleFileBackend::$frozen = false
protected

Definition at line 65 of file SimpleFileBackend.php.

◆ $temporaryCacheDirectory

string TYPO3\CMS\Core\Cache\Backend\SimpleFileBackend::$temporaryCacheDirectory = ''
protected

Temporary path to cache directory before setCache() was called. It is set by setCacheDirectory() and used in setCache() method which calls the directory creation if needed. The variable is not used afterwards, the final cache directory path is stored in $this->cacheDirectory then.

Temporary path to cache directory

Definition at line 51 of file SimpleFileBackend.php.

Referenced by TYPO3\CMS\Core\Cache\Backend\SimpleFileBackend\setCache().

◆ DATASIZE_DIGITS

const TYPO3\CMS\Core\Cache\Backend\SimpleFileBackend::DATASIZE_DIGITS = 10

Definition at line 37 of file SimpleFileBackend.php.

◆ EXPIRYTIME_FORMAT

const TYPO3\CMS\Core\Cache\Backend\SimpleFileBackend::EXPIRYTIME_FORMAT = 'YmdHis'

Definition at line 35 of file SimpleFileBackend.php.

◆ EXPIRYTIME_LENGTH

const TYPO3\CMS\Core\Cache\Backend\SimpleFileBackend::EXPIRYTIME_LENGTH = 14

Definition at line 36 of file SimpleFileBackend.php.

◆ SEPARATOR

const TYPO3\CMS\Core\Cache\Backend\SimpleFileBackend::SEPARATOR = '^'

Definition at line 34 of file SimpleFileBackend.php.