TYPO3CMS  8
 All Classes Namespaces Files Functions Variables Pages
FileBackend Class Reference
Inheritance diagram for FileBackend:
SimpleFileBackend PhpCapableBackendInterface FreezableBackendInterface TaggableBackendInterface AbstractBackend PhpCapableBackendInterface BackendInterface BackendInterface BackendInterface BackendInterface BackendInterface

Public Member Functions

 freeze ()
 
 isFrozen ()
 
 setCache (\TYPO3\CMS\Core\Cache\Frontend\FrontendInterface $cache)
 
 set ($entryIdentifier, $data, array $tags=[], $lifetime=null)
 
 get ($entryIdentifier)
 
 has ($entryIdentifier)
 
 remove ($entryIdentifier)
 
 findIdentifiersByTag ($searchedTag)
 
 flush ()
 
 flushByTag ($tag)
 
 collectGarbage ()
 
 requireOnce ($entryIdentifier)
 
- Public Member Functions inherited from SimpleFileBackend
 setCache (\TYPO3\CMS\Core\Cache\Frontend\FrontendInterface $cache)
 
 setCacheDirectory ($cacheDirectory)
 
 getCacheDirectory ()
 
 set ($entryIdentifier, $data, array $tags=[], $lifetime=null)
 
 get ($entryIdentifier)
 
 has ($entryIdentifier)
 
 remove ($entryIdentifier)
 
 flush ()
 
 collectGarbage ()
 
 requireOnce ($entryIdentifier)
 
- Public Member Functions inherited from AbstractBackend
 __construct ($context, array $options=[])
 
 setCache (\TYPO3\CMS\Core\Cache\Frontend\FrontendInterface $cache)
 
 setDefaultLifetime ($defaultLifetime)
 
 flushByTags (array $tags)
 
- Public Member Functions inherited from TaggableBackendInterface
 flushByTags (array $tags)
 

Public Attributes

const SEPARATOR = '^'
 
const EXPIRYTIME_FORMAT = 'YmdHis'
 
const EXPIRYTIME_LENGTH = 14
 
const DATASIZE_DIGITS = 10
 
- Public Attributes inherited from SimpleFileBackend
const SEPARATOR = '^'
 
const EXPIRYTIME_FORMAT = 'YmdHis'
 
const EXPIRYTIME_LENGTH = 14
 
const DATASIZE_DIGITS = 10
 
- Public Attributes inherited from AbstractBackend
const DATETIME_EXPIRYTIME_UNLIMITED = '9999-12-31T23:59:59+0000'
 
const UNLIMITED_LIFETIME = 0
 

Protected Member Functions

 isCacheFileExpired ($cacheEntryPathAndFilename)
 
 findCacheFilesByIdentifier ($entryIdentifier)
 
- Protected Member Functions inherited from SimpleFileBackend
 createFinalCacheDirectory ($finalCacheDirectory)
 
 isCacheFileExpired ($cacheEntryPathAndFilename)
 
 findCacheFilesByIdentifier ($entryIdentifier)
 
- Protected Member Functions inherited from AbstractBackend
 calculateExpiryTime ($lifetime=null)
 

Protected Attributes

 $cacheEntryFileExtension = ''
 
 $cacheEntryIdentifiers = []
 
 $frozen = false
 
- Protected Attributes inherited from SimpleFileBackend
 $cacheDirectory = ''
 
 $temporaryCacheDirectory = ''
 
 $cacheEntryFileExtension = ''
 
 $cacheEntryIdentifiers = []
 
 $frozen = false
 
- Protected Attributes inherited from AbstractBackend
 $cache
 
 $cacheIdentifier
 
 $context
 
 $defaultLifetime = 3600
 

Detailed Description

A caching backend which stores cache entries in files

This file is a backport from FLOW3

Definition at line 27 of file FileBackend.php.

Member Function Documentation

collectGarbage ( )

Does garbage collection

Returns
void

Implements BackendInterface.

Definition at line 334 of file FileBackend.php.

References FileBackend\isCacheFileExpired().

findCacheFilesByIdentifier (   $entryIdentifier)
protected

Tries to find the cache entry for the specified identifier. Usually only one cache entry should be found - if more than one exist, this is due to some error or crash.

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

Definition at line 362 of file FileBackend.php.

findIdentifiersByTag (   $searchedTag)

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

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

Implements TaggableBackendInterface.

Definition at line 251 of file FileBackend.php.

References $GLOBALS, and GeneralUtility\makeInstance().

Referenced by FileBackend\flushByTag().

flush ( )

Removes all cache entries of this cache and sets the frozen flag to FALSE.

Returns
void

Implements BackendInterface.

Definition at line 284 of file FileBackend.php.

flushByTag (   $tag)

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

Parameters
string$tagThe tag the entries must have
Returns
void

Implements TaggableBackendInterface.

Definition at line 299 of file FileBackend.php.

References FileBackend\findIdentifiersByTag().

freeze ( )

Freezes this cache backend.

All data in a frozen backend remains unchanged and methods which try to add or modify data result in an exception thrown. Possible expiry times of individual cache entries are ignored.

On the positive side, a frozen cache backend is much faster on read access. A frozen backend can only be thawed by calling the flush() method.

Returns
void
Exceptions
RuntimeException

Implements FreezableBackendInterface.

Definition at line 63 of file FileBackend.php.

get (   $entryIdentifier)

Loads data from a cache file.

Parameters
string$entryIdentifierAn 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
InvalidArgumentException If identifier is invalid

Implements BackendInterface.

Definition at line 177 of file FileBackend.php.

References FileBackend\$cacheEntryFileExtension, and FileBackend\isCacheFileExpired().

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
InvalidArgumentException

Implements BackendInterface.

Definition at line 201 of file FileBackend.php.

References FileBackend\isCacheFileExpired().

isCacheFileExpired (   $cacheEntryPathAndFilename)
protected

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

Parameters
string$cacheEntryPathAndFilename
Returns
bool

Definition at line 318 of file FileBackend.php.

References $GLOBALS.

Referenced by FileBackend\collectGarbage(), FileBackend\get(), FileBackend\has(), and FileBackend\requireOnce().

isFrozen ( )

Tells if this backend is frozen.

Returns
bool

Implements FreezableBackendInterface.

Definition at line 90 of file FileBackend.php.

References FileBackend\$frozen.

remove (   $entryIdentifier)

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

Parameters
string$entryIdentifierSpecifies the cache entry to remove
Returns
bool TRUE if (at least) an entry could be removed or FALSE if no entry was found
Exceptions
RuntimeException
InvalidArgumentException

Implements BackendInterface.

Definition at line 222 of file FileBackend.php.

References FileBackend\$cacheEntryFileExtension.

requireOnce (   $entryIdentifier)

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

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

Implements PhpCapableBackendInterface.

Definition at line 380 of file FileBackend.php.

References FileBackend\$cacheEntryFileExtension, and FileBackend\isCacheFileExpired().

set (   $entryIdentifier,
  $data,
array  $tags = [],
  $lifetime = null 
)

Saves data in a cache file.

Parameters
string$entryIdentifierAn identifier for this specific cache entry
string$dataThe data to be stored
array$tagsTags to associate with this cache entry
int$lifetimeLifetime of this cache entry in seconds. If NULL is specified, the default lifetime is used. "0" means unlimited lifetime.
Returns
void
Exceptions
RuntimeException
TYPO3 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.
TYPO3 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.
InvalidArgumentException

Implements BackendInterface.

Definition at line 132 of file FileBackend.php.

References FileBackend\$cacheEntryFileExtension, $GLOBALS, GeneralUtility\fixPermissions(), StringUtility\getUniqueId(), and GeneralUtility\makeInstance().

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

This method also detects if this backend is frozen and sets the internal flag accordingly.

TYPO3 v4 note: This method is different between TYPO3 v4 and FLOW3 because the Environment class to get the path to a temporary directory does not exist in v4.

Parameters
\TYPO3\CMS\Core\Cache\Frontend\FrontendInterface$cacheThe cache frontend
Returns
void

Implements BackendInterface.

Definition at line 109 of file FileBackend.php.

Member Data Documentation

$cacheEntryFileExtension = ''
protected
$cacheEntryIdentifiers = []
protected

Definition at line 43 of file FileBackend.php.

$frozen = false
protected

Definition at line 48 of file FileBackend.php.

Referenced by FileBackend\isFrozen().

const DATASIZE_DIGITS = 10

Definition at line 32 of file FileBackend.php.

const EXPIRYTIME_FORMAT = 'YmdHis'

Definition at line 30 of file FileBackend.php.

const EXPIRYTIME_LENGTH = 14

Definition at line 31 of file FileBackend.php.

const SEPARATOR = '^'

Definition at line 29 of file FileBackend.php.