TYPO3 CMS  TYPO3_6-2
TYPO3\CMS\Core\Cache\Backend\ApcBackend Class Reference
Inheritance diagram for TYPO3\CMS\Core\Cache\Backend\ApcBackend:
TYPO3\CMS\Core\Cache\Backend\AbstractBackend TYPO3\CMS\Core\Cache\Backend\TaggableBackendInterface TYPO3\CMS\Core\Cache\Backend\BackendInterface TYPO3\CMS\Core\Cache\Backend\BackendInterface t3lib_cache_backend_ApcBackend

Public Member Functions

 __construct ($context, array $options=array())
 
 setCache (\TYPO3\CMS\Core\Cache\Frontend\FrontendInterface $cache)
 
 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 TYPO3\CMS\Core\Cache\Backend\AbstractBackend
 __construct ($context, array $options=array())
 
 setCache (\TYPO3\CMS\Core\Cache\Frontend\FrontendInterface $cache)
 
 setDefaultLifetime ($defaultLifetime)
 

Protected Member Functions

 setIdentifierPrefix ($identifierPrefix)
 
 getIdentifierPrefix ()
 
 getCurrentUserData ()
 
 getPathSite ()
 
 findTagsByIdentifier ($identifier)
 
 addIdentifierToTags ($entryIdentifier, array $tags)
 
 removeIdentifierFromAllTags ($entryIdentifier)
 
- Protected Member Functions inherited from TYPO3\CMS\Core\Cache\Backend\AbstractBackend
 calculateExpiryTime ($lifetime=NULL)
 

Protected Attributes

 $identifierPrefix
 
- Protected Attributes inherited from TYPO3\CMS\Core\Cache\Backend\AbstractBackend
 $cache
 
 $cacheIdentifier
 
 $context
 
 $defaultLifetime = 3600
 

Additional Inherited Members

- Public Attributes inherited from TYPO3\CMS\Core\Cache\Backend\AbstractBackend
const DATETIME_EXPIRYTIME_UNLIMITED = '9999-12-31T23:59:59+0000'
 
const UNLIMITED_LIFETIME = 0
 

Detailed Description

This file is part of the TYPO3 CMS project.

It is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, either version 2 of the License, or any later version.

For the full copyright and license information, please read the LICENSE.txt file that was distributed with this source code.

The TYPO3 project - inspiring people to share! A caching backend which stores cache entries by using APC.

This backend uses the following types of keys:

  • tag_xxx xxx is tag name, value is array of associated identifiers identifier. This is "forward" tag index. It is mainly used for obtaining content by tag (get identifier by tag -> get content by identifier)
  • ident_xxx xxx is identifier, value is array of associated tags. This is "reverse" tag index. It provides quick access for all tags associated with this identifier and used when removing the identifier

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:

  • "TYPO3"
  • MD5 of path to TYPO3 and user running TYPO3 This prefix makes sure that keys from the different installations do not conflict.

This file is a backport from FLOW3

Author
Robert Lemke rober.nosp@m.t@ty.nosp@m.po3.o.nosp@m.rg
Karsten Dambekalns karst.nosp@m.en@t.nosp@m.ypo3..nosp@m.org
Christian Jul Jensen julle.nosp@m.@typ.nosp@m.o3.or.nosp@m.g
Dmitry Dulepov dmitr.nosp@m.y@ty.nosp@m.po3.o.nosp@m.rg

Definition at line 44 of file ApcBackend.php.

Constructor & Destructor Documentation

◆ __construct()

TYPO3\CMS\Core\Cache\Backend\ApcBackend::__construct (   $context,
array  $options = array() 
)

Constructs this backend

Parameters
string$contextFLOW3's application context
array$optionsConfiguration options - unused here
Exceptions

Definition at line 78 of file ApcBackend.php.

References TYPO3\CMS\Core\Cache\Backend\AbstractBackend\$context.

Member Function Documentation

◆ addIdentifierToTags()

TYPO3\CMS\Core\Cache\Backend\ApcBackend::addIdentifierToTags (   $entryIdentifier,
array  $tags 
)
protected

Associates the identifier with the given tags

Parameters
string$entryIdentifier
array$tags
Returns
void

Definition at line 256 of file ApcBackend.php.

References TYPO3\CMS\Core\Cache\Backend\ApcBackend\findIdentifiersByTag(), TYPO3\CMS\Core\Cache\Backend\ApcBackend\findTagsByIdentifier(), and TYPO3\CMS\Core\Cache\Backend\ApcBackend\getIdentifierPrefix().

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

◆ collectGarbage()

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

Does nothing, as APC does GC itself

Returns
void

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

Definition at line 316 of file ApcBackend.php.

◆ findIdentifiersByTag()

TYPO3\CMS\Core\Cache\Backend\ApcBackend::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 TYPO3\CMS\Core\Cache\Backend\TaggableBackendInterface.

Definition at line 198 of file ApcBackend.php.

References TYPO3\CMS\Core\Cache\Backend\ApcBackend\getIdentifierPrefix().

Referenced by TYPO3\CMS\Core\Cache\Backend\ApcBackend\addIdentifierToTags(), TYPO3\CMS\Core\Cache\Backend\ApcBackend\flushByTag(), and TYPO3\CMS\Core\Cache\Backend\ApcBackend\removeIdentifierFromAllTags().

◆ findTagsByIdentifier()

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

References TYPO3\CMS\Core\Cache\Backend\ApcBackend\getIdentifierPrefix().

Referenced by TYPO3\CMS\Core\Cache\Backend\ApcBackend\addIdentifierToTags(), and TYPO3\CMS\Core\Cache\Backend\ApcBackend\removeIdentifierFromAllTags().

◆ flush()

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

Removes all cache entries of this cache.

Returns
void
Exceptions

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

Definition at line 228 of file ApcBackend.php.

References TYPO3\CMS\Core\Cache\Backend\ApcBackend\flushByTag().

◆ flushByTag()

TYPO3\CMS\Core\Cache\Backend\ApcBackend::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 TYPO3\CMS\Core\Cache\Backend\TaggableBackendInterface.

Definition at line 242 of file ApcBackend.php.

References TYPO3\CMS\Core\Cache\Backend\ApcBackend\findIdentifiersByTag().

Referenced by TYPO3\CMS\Core\Cache\Backend\ApcBackend\flush().

◆ get()

TYPO3\CMS\Core\Cache\Backend\ApcBackend::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 TYPO3\CMS\Core\Cache\Backend\BackendInterface.

Definition at line 157 of file ApcBackend.php.

References TYPO3\CMS\Core\Cache\Backend\ApcBackend\getIdentifierPrefix().

◆ getCurrentUserData()

TYPO3\CMS\Core\Cache\Backend\ApcBackend::getCurrentUserData ( )
protected

Returns the current user data with posix_getpwuid or a default structure when posix_getpwuid is not available.

Returns
array

Definition at line 107 of file ApcBackend.php.

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

◆ getIdentifierPrefix()

◆ getPathSite()

TYPO3\CMS\Core\Cache\Backend\ApcBackend::getPathSite ( )
protected

Returns the PATH_site constant.

Returns
string

Definition at line 116 of file ApcBackend.php.

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

◆ has()

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

Checks if a cache entry with the specified identifier exists.

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

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

Definition at line 170 of file ApcBackend.php.

References TYPO3\CMS\Core\Cache\Backend\ApcBackend\getIdentifierPrefix().

◆ remove()

TYPO3\CMS\Core\Cache\Backend\ApcBackend::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
boolean 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 185 of file ApcBackend.php.

References TYPO3\CMS\Core\Cache\Backend\ApcBackend\getIdentifierPrefix(), and TYPO3\CMS\Core\Cache\Backend\ApcBackend\removeIdentifierFromAllTags().

◆ removeIdentifierFromAllTags()

TYPO3\CMS\Core\Cache\Backend\ApcBackend::removeIdentifierFromAllTags (   $entryIdentifier)
protected

◆ set()

TYPO3\CMS\Core\Cache\Backend\ApcBackend::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
integer$lifetimeLifetime of this cache entry in seconds. If NULL is specified, the default lifetime is used. "0" means unlimited liftime.
Returns
void
Exceptions

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

Definition at line 132 of file ApcBackend.php.

References TYPO3\CMS\Core\Cache\Backend\AbstractBackend\$cacheIdentifier, TYPO3\CMS\Core\Cache\Backend\AbstractBackend\$defaultLifetime, TYPO3\CMS\Core\Cache\Backend\ApcBackend\addIdentifierToTags(), TYPO3\CMS\Core\Cache\Backend\ApcBackend\getIdentifierPrefix(), and TYPO3\CMS\Core\Cache\Backend\ApcBackend\removeIdentifierFromAllTags().

◆ setCache()

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

Initializes the identifier prefix when setting the cache.

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

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

Definition at line 94 of file ApcBackend.php.

References TYPO3\CMS\Core\Cache\Backend\ApcBackend\getCurrentUserData(), TYPO3\CMS\Core\Cache\Backend\ApcBackend\getPathSite(), TYPO3\CMS\Core\Cache\Backend\ApcBackend\setIdentifierPrefix(), and TYPO3\CMS\Core\Utility\GeneralUtility\shortMD5().

◆ setIdentifierPrefix()

TYPO3\CMS\Core\Cache\Backend\ApcBackend::setIdentifierPrefix (   $identifierPrefix)
protected

Set the cache identifier prefix.

Parameters
string$identifierPrefix

Definition at line 58 of file ApcBackend.php.

References TYPO3\CMS\Core\Cache\Backend\ApcBackend\$identifierPrefix.

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

Member Data Documentation

◆ $identifierPrefix

TYPO3\CMS\Core\Cache\Backend\ApcBackend::$identifierPrefix
protected