TYPO3 CMS  TYPO3_6-2
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 t3lib_cache_backend_RedisBackend

Public Member Functions

 __construct ($context, array $options=array())
 
 initializeObject ()
 
 setHostname ($hostname)
 
 setPort ($port)
 
 setDatabase ($database)
 
 setPassword ($password)
 
 setCompression ($compression)
 
 setCompressionLevel ($compressionLevel)
 
 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)
 

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)
 
- Protected Member Functions inherited from TYPO3\CMS\Core\Cache\Backend\AbstractBackend
 calculateExpiryTime ($lifetime=NULL)
 

Protected Attributes

 $redis
 
 $connected = 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

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 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
Author
Christopher Hlubek hlube.nosp@m.k@ne.nosp@m.twork.nosp@m.team.nosp@m..com
Christian Kuhn lolli.nosp@m.@sch.nosp@m.warzb.nosp@m.u.ch

Definition at line 27 of file RedisBackend.php.

Constructor & Destructor Documentation

◆ __construct()

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

Construct this backend

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

Definition at line 124 of file RedisBackend.php.

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

Member Function Documentation

◆ 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 447 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 388 of file RedisBackend.php.

◆ 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 407 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 424 of file RedisBackend.php.

References 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 314 of file RedisBackend.php.

◆ 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
boolean TRUE if such an entry exists, FALSE if not
Exceptions

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

Definition at line 338 of file RedisBackend.php.

◆ initializeObject()

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

Initializes the redis backend

Returns
void
Exceptions

Definition at line 137 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
boolean 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 356 of file RedisBackend.php.

◆ 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 475 of file RedisBackend.php.

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

◆ set()

TYPO3\CMS\Core\Cache\Backend\RedisBackend::set (   $entryIdentifier,
  $data,
array  $tags = array(),
  $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
integer$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 262 of file RedisBackend.php.

◆ setCompression()

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

Enable data compression

Parameters
boolean$compressionTRUE to enable compression
Returns
void
Exceptions

Definition at line 219 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
integer$compressionLevel-1 to 9: Compression level
Returns
void
Exceptions

Definition at line 236 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
integer$databaseDatabase
Returns
void
Exceptions

Definition at line 190 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 167 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 207 of file RedisBackend.php.

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

◆ setPort()

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

Setter for server port

Parameters
integer$portPort
Returns
void

Definition at line 178 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 73 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

◆ $port

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

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

◆ FAKED_UNLIMITED_LIFETIME

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

Definition at line 42 of file RedisBackend.php.

◆ IDENTIFIER_DATA_PREFIX

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

Definition at line 48 of file RedisBackend.php.

◆ IDENTIFIER_TAGS_PREFIX

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

Definition at line 54 of file RedisBackend.php.

◆ TAG_IDENTIFIERS_PREFIX

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

Definition at line 60 of file RedisBackend.php.