TYPO3 CMS  TYPO3_7-6
TYPO3\CMS\Core\Cache\Backend\RedisBackend Class Reference
Inheritance diagram for TYPO3\CMS\Core\Cache\Backend\RedisBackend:
TYPO3\CMS\Core\Cache\Backend\AbstractBackend TYPO3\CMS\Core\Cache\Backend\TaggableBackendInterface TYPO3\CMS\Core\Cache\Backend\BackendInterface TYPO3\CMS\Core\Cache\Backend\BackendInterface

Public Member Functions

 __construct ($context, array $options=[])
 
 initializeObject ()
 
 setPersistentConnection ($persistentConnection)
 
 setHostname ($hostname)
 
 setPort ($port)
 
 setDatabase ($database)
 
 setPassword ($password)
 
 setCompression ($compression)
 
 setCompressionLevel ($compressionLevel)
 
 set ($entryIdentifier, $data, array $tags=[], $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=[])
 
 setCache (\TYPO3\CMS\Core\Cache\Frontend\FrontendInterface $cache)
 
 setDefaultLifetime ($defaultLifetime)
 

Public Attributes

const FAKED_UNLIMITED_LIFETIME = 31536000
 
const IDENTIFIER_DATA_PREFIX = 'identData:'
 
const IDENTIFIER_TAGS_PREFIX = 'identTags:'
 
const TAG_IDENTIFIERS_PREFIX = 'tagIdents:'
 
- Public Attributes inherited from TYPO3\CMS\Core\Cache\Backend\AbstractBackend
const DATETIME_EXPIRYTIME_UNLIMITED = '9999-12-31T23:59:59+0000'
 
const UNLIMITED_LIFETIME = 0
 

Protected Member Functions

 removeIdentifierEntriesAndRelations (array $identifiers, array $tags)
 
 canBeUsedInStringContext ($variable)
 
- Protected Member Functions inherited from TYPO3\CMS\Core\Cache\Backend\AbstractBackend
 calculateExpiryTime ($lifetime=null)
 

Protected Attributes

 $redis
 
 $connected = false
 
 $persistentConnection = false
 
 $hostname = '127.0.0.1'
 
 $port = 6379
 
 $database = 0
 
 $password = ''
 
 $compression = false
 
 $compressionLevel = -1
 
- Protected Attributes inherited from TYPO3\CMS\Core\Cache\Backend\AbstractBackend
 $cache
 
 $cacheIdentifier
 
 $context
 
 $defaultLifetime = 3600
 

Detailed Description

A caching backend which stores cache entries by using Redis with phpredis PHP module. Redis is a noSQL database with very good scaling characteristics in proportion to the amount of entries and data size.

See also
http://code.google.com/p/redis/
http://github.com/owlient/phpredis

Definition at line 28 of file RedisBackend.php.

Constructor & Destructor Documentation

◆ __construct()

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

Construct this backend

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

Definition at line 132 of file RedisBackend.php.

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

Member Function Documentation

◆ canBeUsedInStringContext()

TYPO3\CMS\Core\Cache\Backend\RedisBackend::canBeUsedInStringContext (   $variable)
protected

◆ collectGarbage()

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

With the current internal structure, only the identifier to data entries have a redis internal lifetime. If an entry expires, attached identifier to tags and tag to identifiers entries will be left over. This methods finds those entries and cleans them up.

Scales O(n*m) with number of cache entries (n) and number of tags (m)

Returns
void

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

Definition at line 486 of file RedisBackend.php.

◆ findIdentifiersByTag()

TYPO3\CMS\Core\Cache\Backend\RedisBackend::findIdentifiersByTag (   $tag)

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

Scales O(1) with number of cache entries Scales O(n) with number of tag entries

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

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

Definition at line 424 of file RedisBackend.php.

References TYPO3\CMS\Core\Cache\Backend\RedisBackend\canBeUsedInStringContext().

◆ flush()

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

Removes all cache entries of this cache.

Scales O(1) with number of cache entries

Returns
void

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

Definition at line 444 of file RedisBackend.php.

◆ flushByTag()

TYPO3\CMS\Core\Cache\Backend\RedisBackend::flushByTag (   $tag)

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

Scales O(1) with number of cache entries Scales O(n^2) with number of tag entries

Parameters
string$tagTag the entries must have
Returns
void
Exceptions

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

Definition at line 462 of file RedisBackend.php.

References TYPO3\CMS\Core\Cache\Backend\RedisBackend\canBeUsedInStringContext(), and TYPO3\CMS\Core\Cache\Backend\RedisBackend\removeIdentifierEntriesAndRelations().

◆ get()

TYPO3\CMS\Core\Cache\Backend\RedisBackend::get (   $entryIdentifier)

Loads data from the cache.

Scales O(1) with number of cache entries

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

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

Definition at line 347 of file RedisBackend.php.

References TYPO3\CMS\Core\Cache\Backend\RedisBackend\canBeUsedInStringContext().

◆ has()

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

Checks if a cache entry with the specified identifier exists.

Scales O(1) with number of cache entries

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

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

Definition at line 372 of file RedisBackend.php.

References TYPO3\CMS\Core\Cache\Backend\RedisBackend\canBeUsedInStringContext().

◆ initializeObject()

TYPO3\CMS\Core\Cache\Backend\RedisBackend::initializeObject ( )

Initializes the redis backend

Returns
void
Exceptions

Definition at line 146 of file RedisBackend.php.

References TYPO3\CMS\Core\Utility\GeneralUtility\SYSLOG_SEVERITY_ERROR.

◆ remove()

TYPO3\CMS\Core\Cache\Backend\RedisBackend::remove (   $entryIdentifier)

Removes all cache entries matching the specified identifier.

Scales O(1) with number of cache entries Scales O(n) with number of tags

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

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

Definition at line 391 of file RedisBackend.php.

References TYPO3\CMS\Core\Cache\Backend\RedisBackend\canBeUsedInStringContext().

◆ removeIdentifierEntriesAndRelations()

TYPO3\CMS\Core\Cache\Backend\RedisBackend::removeIdentifierEntriesAndRelations ( array  $identifiers,
array  $tags 
)
protected

Helper method for flushByTag() Gets list of identifiers and tags and removes all relations of those tags

Scales O(1) with number of cache entries Scales O(n^2) with number of tags

Parameters
array$identifiersList of identifiers to remove
array$tagsList of tags to be handled
Returns
void

Definition at line 515 of file RedisBackend.php.

References TYPO3\CMS\Core\Utility\StringUtility\getUniqueId().

Referenced by TYPO3\CMS\Core\Cache\Backend\RedisBackend\flushByTag().

◆ set()

TYPO3\CMS\Core\Cache\Backend\RedisBackend::set (   $entryIdentifier,
  $data,
array  $tags = [],
  $lifetime = null 
)

Save data in the cache

Scales O(1) with number of cache entries Scales O(n) with number of tags

Parameters
string$entryIdentifierIdentifier for this specific cache entry
string$dataData to be stored
array$tagsTags to associate with this cache entry
int$lifetimeLifetime of this cache entry in seconds. If NULL is specified, default lifetime is used. "0" means unlimited lifetime.
Returns
void
Exceptions

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

Definition at line 294 of file RedisBackend.php.

References TYPO3\CMS\Core\Cache\Backend\RedisBackend\canBeUsedInStringContext().

◆ setCompression()

TYPO3\CMS\Core\Cache\Backend\RedisBackend::setCompression (   $compression)

Enable data compression

Parameters
bool$compressionTRUE to enable compression
Returns
void
Exceptions

Definition at line 249 of file RedisBackend.php.

References TYPO3\CMS\Core\Cache\Backend\RedisBackend\$compression.

◆ setCompressionLevel()

TYPO3\CMS\Core\Cache\Backend\RedisBackend::setCompressionLevel (   $compressionLevel)

Set data compression level. If compression is enabled and this is not set, gzcompress default level will be used.

Parameters
int$compressionLevel-1 to 9: Compression level
Returns
void
Exceptions

Definition at line 267 of file RedisBackend.php.

References TYPO3\CMS\Core\Cache\Backend\RedisBackend\$compressionLevel.

◆ setDatabase()

TYPO3\CMS\Core\Cache\Backend\RedisBackend::setDatabase (   $database)

Setter for database number

Parameters
int$databaseDatabase
Returns
void
Exceptions

Definition at line 218 of file RedisBackend.php.

References TYPO3\CMS\Core\Cache\Backend\RedisBackend\$database.

◆ setHostname()

TYPO3\CMS\Core\Cache\Backend\RedisBackend::setHostname (   $hostname)

Setter for server hostname

Parameters
string$hostnameHostname
Returns
void

Definition at line 193 of file RedisBackend.php.

References TYPO3\CMS\Core\Cache\Backend\RedisBackend\$hostname.

◆ setPassword()

TYPO3\CMS\Core\Cache\Backend\RedisBackend::setPassword (   $password)

Setter for authentication password

Parameters
string$passwordPassword
Returns
void

Definition at line 236 of file RedisBackend.php.

References TYPO3\CMS\Core\Cache\Backend\RedisBackend\$password.

◆ setPersistentConnection()

TYPO3\CMS\Core\Cache\Backend\RedisBackend::setPersistentConnection (   $persistentConnection)

Setter for persistent connection

Parameters
bool$persistentConnection
Returns
void

Definition at line 181 of file RedisBackend.php.

References TYPO3\CMS\Core\Cache\Backend\RedisBackend\$persistentConnection.

◆ setPort()

TYPO3\CMS\Core\Cache\Backend\RedisBackend::setPort (   $port)

Setter for server port

Parameters
int$portPort
Returns
void

Definition at line 205 of file RedisBackend.php.

References TYPO3\CMS\Core\Cache\Backend\RedisBackend\$port.

Member Data Documentation

◆ $compression

TYPO3\CMS\Core\Cache\Backend\RedisBackend::$compression = false
protected

◆ $compressionLevel

TYPO3\CMS\Core\Cache\Backend\RedisBackend::$compressionLevel = -1
protected

◆ $connected

TYPO3\CMS\Core\Cache\Backend\RedisBackend::$connected = false
protected

Definition at line 74 of file RedisBackend.php.

◆ $database

TYPO3\CMS\Core\Cache\Backend\RedisBackend::$database = 0
protected

◆ $hostname

TYPO3\CMS\Core\Cache\Backend\RedisBackend::$hostname = '127.0.0.1'
protected

◆ $password

TYPO3\CMS\Core\Cache\Backend\RedisBackend::$password = ''
protected

◆ $persistentConnection

TYPO3\CMS\Core\Cache\Backend\RedisBackend::$persistentConnection = false
protected

◆ $port

TYPO3\CMS\Core\Cache\Backend\RedisBackend::$port = 6379
protected

Definition at line 95 of file RedisBackend.php.

Referenced by TYPO3\CMS\Core\Cache\Backend\RedisBackend\setPort().

◆ $redis

TYPO3\CMS\Core\Cache\Backend\RedisBackend::$redis
protected

Definition at line 67 of file RedisBackend.php.

◆ FAKED_UNLIMITED_LIFETIME

const TYPO3\CMS\Core\Cache\Backend\RedisBackend::FAKED_UNLIMITED_LIFETIME = 31536000

Definition at line 43 of file RedisBackend.php.

◆ IDENTIFIER_DATA_PREFIX

const TYPO3\CMS\Core\Cache\Backend\RedisBackend::IDENTIFIER_DATA_PREFIX = 'identData:'

Definition at line 49 of file RedisBackend.php.

◆ IDENTIFIER_TAGS_PREFIX

const TYPO3\CMS\Core\Cache\Backend\RedisBackend::IDENTIFIER_TAGS_PREFIX = 'identTags:'

Definition at line 55 of file RedisBackend.php.

◆ TAG_IDENTIFIERS_PREFIX

const TYPO3\CMS\Core\Cache\Backend\RedisBackend::TAG_IDENTIFIERS_PREFIX = 'tagIdents:'

Definition at line 61 of file RedisBackend.php.