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

Public Member Functions

 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 Attributes

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

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

Protected Attributes

 $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, but does not support or care about expiry times and tags.

Definition at line 24 of file SimpleFileBackend.php.

Member Function Documentation

collectGarbage ( )

Not necessary

Returns
void

Implements BackendInterface.

Definition at line 337 of file SimpleFileBackend.php.

createFinalCacheDirectory (   $finalCacheDirectory)
protected

Create the final cache directory if it does not exist. This method exists in TYPO3 v4 only.

Parameters
string$finalCacheDirectoryAbsolute path to final cache directory
Returns
void
Exceptions
TYPO3 If directory is not writable after creation

Definition at line 186 of file SimpleFileBackend.php.

References GeneralUtility\mkdir_deep().

Referenced by SimpleFileBackend\setCache().

findCacheFilesByIdentifier (   $entryIdentifier)
protected

Tries to find the cache entry for the specified identifier.

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

Definition at line 347 of file SimpleFileBackend.php.

References SimpleFileBackend\$cacheEntryFileExtension.

flush ( )

Removes all cache entries of this cache.

Returns
void

Implements BackendInterface.

Definition at line 313 of file SimpleFileBackend.php.

References GeneralUtility\flushDirectory().

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 254 of file SimpleFileBackend.php.

References SimpleFileBackend\$cacheEntryFileExtension.

getCacheDirectory ( )

Returns the directory where the cache files are stored

Returns
string Full path of the cache directory

Definition at line 204 of file SimpleFileBackend.php.

References SimpleFileBackend\$cacheDirectory.

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 274 of file SimpleFileBackend.php.

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 326 of file SimpleFileBackend.php.

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
InvalidArgumentException

Implements BackendInterface.

Definition at line 291 of file SimpleFileBackend.php.

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
Returns
mixed Potential return value from the include operation
Exceptions
InvalidArgumentException

Implements PhpCapableBackendInterface.

Definition at line 361 of file SimpleFileBackend.php.

References SimpleFileBackend\$cacheEntryFileExtension.

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$lifetimeThis cache backend does not support life times
Returns
void
Exceptions
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 data to bes stored is not a string.
InvalidArgumentException

Implements BackendInterface.

Definition at line 222 of file SimpleFileBackend.php.

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

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

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
Exceptions
TYPO3
Returns
void

Implements BackendInterface.

Definition at line 77 of file SimpleFileBackend.php.

References SimpleFileBackend\$temporaryCacheDirectory, and SimpleFileBackend\createFinalCacheDirectory().

setCacheDirectory (   $cacheDirectory)

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

This method does not exist in FLOW3 anymore, but it is needed in TYPO3 v4 to enable a cache path outside of document root. The final cache path is checked and created in createFinalCachDirectory(), called by setCache() method, which is done after the cacheDirectory option was handled.

Parameters
string$cacheDirectoryThe cache base directory. If a relative path
Returns
void
Exceptions
TYPO3 if the directory is not within allowed

Definition at line 115 of file SimpleFileBackend.php.

References SimpleFileBackend\$cacheDirectory, and GeneralUtility\isFirstPartOfStr().

Member Data Documentation

$cacheDirectory = ''
protected
$cacheEntryIdentifiers = []
protected

Definition at line 58 of file SimpleFileBackend.php.

$frozen = false
protected

Definition at line 63 of file SimpleFileBackend.php.

$temporaryCacheDirectory = ''
protected

Definition at line 46 of file SimpleFileBackend.php.

Referenced by SimpleFileBackend\setCache().

const DATASIZE_DIGITS = 10

Definition at line 29 of file SimpleFileBackend.php.

const EXPIRYTIME_FORMAT = 'YmdHis'

Definition at line 27 of file SimpleFileBackend.php.

const EXPIRYTIME_LENGTH = 14

Definition at line 28 of file SimpleFileBackend.php.

const SEPARATOR = '^'

Definition at line 26 of file SimpleFileBackend.php.