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

Public Member Functions

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

Public Attributes

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

Protected Member Functions

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

Protected Attributes

 $memcache
 
 $servers = array()
 
 $flags
 
 $identifierPrefix
 
- Protected Attributes inherited from AbstractBackend
 $cache
 
 $cacheIdentifier
 
 $context
 
 $defaultLifetime = 3600
 

Detailed Description

A caching backend which stores cache entries by using Memcached.

This backend uses the following types of Memcache 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:

Note: When using the Memcached backend to store values of more than ~1 MB, the data will be split into chunks to make them fit into the memcached limits.

This file is a backport from FLOW3 by Ingo Renner.

Definition at line 43 of file MemcachedBackend.php.

Constructor & Destructor Documentation

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

Constructs this backend

Parameters
string$contextFLOW3's application context
array$optionsConfiguration options - depends on the actual backend
Exceptions
\TYPO3\CMS\Core\Cache\Exceptionif memcache is not installed

Definition at line 87 of file MemcachedBackend.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 326 of file MemcachedBackend.php.

References MemcachedBackend\findIdentifiersByTag(), and MemcachedBackend\findTagsByIdentifier().

Referenced by MemcachedBackend\set().

collectGarbage ( )

Does nothing, as memcached does GC itself

Returns
void

Implements BackendInterface.

Definition at line 404 of file MemcachedBackend.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 of entries with all matching entries. An empty array if no entries matched

Implements TaggableBackendInterface.

Definition at line 279 of file MemcachedBackend.php.

Referenced by MemcachedBackend\addIdentifierToTags(), MemcachedBackend\flushByTag(), and MemcachedBackend\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

Definition at line 392 of file MemcachedBackend.php.

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

flush ( )

Removes all cache entries of this cache.

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

Implements BackendInterface.

Definition at line 296 of file MemcachedBackend.php.

References MemcachedBackend\flushByTag().

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 311 of file MemcachedBackend.php.

References MemcachedBackend\findIdentifiersByTag().

Referenced by MemcachedBackend\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 231 of file MemcachedBackend.php.

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 251 of file MemcachedBackend.php.

initializeObject ( )

Initializes the identifier prefix

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

Definition at line 130 of file MemcachedBackend.php.

References $server.

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 265 of file MemcachedBackend.php.

References MemcachedBackend\removeIdentifierFromAllTags().

removeIdentifierFromAllTags (   $entryIdentifier)
protected

Removes association of the identifier with the given tags

Parameters
string$entryIdentifier
arrayArray of tags
Returns
void

Definition at line 359 of file MemcachedBackend.php.

References MemcachedBackend\findIdentifiersByTag(), and MemcachedBackend\findTagsByIdentifier().

Referenced by MemcachedBackend\remove(), and MemcachedBackend\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 lifetime.
Returns
void
Exceptions
\TYPO3\CMS\Core\Cache\Exceptionif no cache frontend has been set.
\InvalidArgumentExceptionif the identifier is not valid or the final memcached key is longer than 250 characters
\TYPO3\CMS\Core\Cache\Exception\InvalidDataExceptionif $data is not a string

Implements BackendInterface.

Definition at line 182 of file MemcachedBackend.php.

References AbstractBackend\$cacheIdentifier, AbstractBackend\$defaultLifetime, $GLOBALS, MemcachedBackend\addIdentifierToTags(), and MemcachedBackend\removeIdentifierFromAllTags().

Initializes the identifier prefix when setting the cache.

Parameters
\TYPO3\CMS\Core\Cache\Frontend\FrontendInterface$cacheThe frontend for this backend
Returns
void

Implements BackendInterface.

Definition at line 162 of file MemcachedBackend.php.

setCompression (   $useCompression)
protected

Setter for compression flags bit

Parameters
bool$useCompression
Returns
void

Definition at line 115 of file MemcachedBackend.php.

setServers ( array  $servers)
protected

Setter for servers to be used. Expects an array, the values are expected to be formatted like "<host>[:<port>]" or "unix://<path>"

Parameters
array$serversAn array of servers to add.
Returns
void

Definition at line 103 of file MemcachedBackend.php.

References MemcachedBackend\$servers.

Member Data Documentation

$flags
protected

Definition at line 71 of file MemcachedBackend.php.

$identifierPrefix
protected

Definition at line 78 of file MemcachedBackend.php.

$memcache
protected

Definition at line 56 of file MemcachedBackend.php.

$servers = array()
protected

Definition at line 63 of file MemcachedBackend.php.

Referenced by MemcachedBackend\setServers().

const MAX_BUCKET_SIZE = 1048534

Definition at line 50 of file MemcachedBackend.php.