TYPO3  7.6
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
XcacheBackend Class Reference
Inheritance diagram for XcacheBackend:
AbstractBackend TaggableBackendInterface BackendInterface BackendInterface

Public Member Functions

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

Protected Member Functions

 findTagsByIdentifier ($identifier)
 
 addIdentifierToTags ($entryIdentifier, array $tags)
 
 removeIdentifierFromAllTags ($entryIdentifier)
 
 runningFromCliOrWrongConfiguration ()
 
- Protected Member Functions inherited from AbstractBackend
 calculateExpiryTime ($lifetime=null)
 

Protected Attributes

 $identifierPrefix
 
- Protected Attributes inherited from AbstractBackend
 $cache
 
 $cacheIdentifier
 
 $context
 
 $defaultLifetime = 3600
 

Additional Inherited Members

- Public Attributes inherited from AbstractBackend
const DATETIME_EXPIRYTIME_UNLIMITED = '9999-12-31T23:59:59+0000'
 
const UNLIMITED_LIFETIME = 0
 

Detailed Description

A caching backend which stores cache entries by using xcache opcode cache.

This backend uses the following types of keys:

Each key is prepended with a prefix. By default prefix consists from two parts separated by underscore character and ends in yet another underscore character:

Definition at line 39 of file XcacheBackend.php.

Constructor & Destructor Documentation

__construct (   $context,
array  $options = array() 
)

Constructs this backend

Parameters
string$contextFLOW3's application context
array$optionsConfiguration options
Exceptions
\TYPO3\CMS\Core\Cache\ExceptionIf xcache PHP extension is not loaded

Definition at line 55 of file XcacheBackend.php.

References AbstractBackend\$context.

Member Function Documentation

addIdentifierToTags (   $entryIdentifier,
array  $tags 
)
protected

Associates the identifier with the given tags

Parameters
string$entryIdentifier
array$tags
Returns
void

Definition at line 228 of file XcacheBackend.php.

References XcacheBackend\findIdentifiersByTag(), XcacheBackend\findTagsByIdentifier(), and XcacheBackend\runningFromCliOrWrongConfiguration().

Referenced by XcacheBackend\set().

collectGarbage ( )

Does nothing, as xcache does GC itself

Returns
void

Implements BackendInterface.

Definition at line 298 of file XcacheBackend.php.

findIdentifiersByTag (   $tag)

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

Parameters
string$tagThe 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 161 of file XcacheBackend.php.

References XcacheBackend\runningFromCliOrWrongConfiguration().

Referenced by XcacheBackend\addIdentifierToTags(), XcacheBackend\flushByTag(), and XcacheBackend\removeIdentifierFromAllTags().

findTagsByIdentifier (   $identifier)
protected

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

Parameters
string$identifierIdentifier to find tags by
Returns
array Array with tags

Definition at line 177 of file XcacheBackend.php.

References XcacheBackend\runningFromCliOrWrongConfiguration().

Referenced by XcacheBackend\addIdentifierToTags(), and XcacheBackend\removeIdentifierFromAllTags().

flush ( )

Removes all cache entries of this cache

Returns
void
Exceptions
\TYPO3\CMS\Core\Cache\Exception

Implements BackendInterface.

Definition at line 192 of file XcacheBackend.php.

References XcacheBackend\flushByTag(), and XcacheBackend\runningFromCliOrWrongConfiguration().

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 213 of file XcacheBackend.php.

References XcacheBackend\findIdentifiersByTag().

Referenced by XcacheBackend\flush().

get (   $entryIdentifier)

Loads data from the cache

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

Implements BackendInterface.

Definition at line 114 of file XcacheBackend.php.

References XcacheBackend\runningFromCliOrWrongConfiguration().

has (   $entryIdentifier)

Checks if a cache entry with the specified identifier exists

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

Implements BackendInterface.

Definition at line 129 of file XcacheBackend.php.

References XcacheBackend\runningFromCliOrWrongConfiguration().

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$entryIdentifierSpecifies the cache entry to remove
Returns
bool TRUE if (at least) an entry could be removed or FALSE if no entry was found

Implements BackendInterface.

Definition at line 145 of file XcacheBackend.php.

References XcacheBackend\removeIdentifierFromAllTags(), and XcacheBackend\runningFromCliOrWrongConfiguration().

removeIdentifierFromAllTags (   $entryIdentifier)
protected

Removes association of the identifier with the given tags

Parameters
string$entryIdentifier
Returns
void

Definition at line 265 of file XcacheBackend.php.

References XcacheBackend\findIdentifiersByTag(), XcacheBackend\findTagsByIdentifier(), and XcacheBackend\runningFromCliOrWrongConfiguration().

Referenced by XcacheBackend\remove(), and XcacheBackend\set().

runningFromCliOrWrongConfiguration ( )
protected

Checks if backend is called from CLI context. In this case all methods fail silently as xcache user cache is not available in CLI context. xcache.var_size cat be zero or empty if in CLI mode, or if not correctly configured.

Returns
bool TRUE if misconfigured or in CLI mode

Definition at line 309 of file XcacheBackend.php.

Referenced by XcacheBackend\addIdentifierToTags(), XcacheBackend\findIdentifiersByTag(), XcacheBackend\findTagsByIdentifier(), XcacheBackend\flush(), XcacheBackend\get(), XcacheBackend\has(), XcacheBackend\remove(), XcacheBackend\removeIdentifierFromAllTags(), and XcacheBackend\set().

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

Saves data in the cache

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 liftime.
Returns
void
Exceptions
\TYPO3\CMS\Core\Cache\Exceptionif no cache frontend has been set
\TYPO3\CMS\Core\Cache\Exception\InvalidDataExceptionif $data is not a string

Implements BackendInterface.

Definition at line 77 of file XcacheBackend.php.

References AbstractBackend\$defaultLifetime, XcacheBackend\addIdentifierToTags(), XcacheBackend\removeIdentifierFromAllTags(), and XcacheBackend\runningFromCliOrWrongConfiguration().

Member Data Documentation

$identifierPrefix
protected

Definition at line 46 of file XcacheBackend.php.