Elgg  Version 6.1
Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | List of all members
Elgg\Cache\CompositeCache Class Reference

Composite cache pool. More...

Inheritance diagram for Elgg\Cache\CompositeCache:
Elgg\Cache\BaseCache

Public Member Functions

 __construct (protected string $namespace, protected Config $config, protected int $flags, protected bool $validate_lastcache=true)
 Constructor. More...
 
 save ($key, $data, $expire_after=null)
 Save data in a cache. More...
 
 load ($key)
 Load data from the cache using a given key. More...
 
 delete ($key)
 {} More...
 
 clear ()
 {} More...
 
 invalidate ()
 {} More...
 
 purge ()
 {} More...
 
 setNamespace ($namespace= 'default')
 Set the namespace of this cache. More...
 
 getNamespace ()
 Get the namespace currently defined. More...
 
- Public Member Functions inherited from Elgg\Cache\BaseCache
 setVariable (string $variable, $value)
 Set a cache variable. More...
 
 getVariable (string $variable)
 Get variables for this cache. More...
 
 __get (string $key)
 Class member get overloading, returning key using $this->load defaults. More...
 
 __set (string $key, $value)
 Class member set overloading, setting a key using $this->save defaults. More...
 
 __isset (string $key)
 Supporting isset, using $this->load() with default values. More...
 
 __unset (string $key)
 Supporting unsetting of magic attributes. More...
 
 save ($key, $data, $expire_after=null)
 Save data in a cache. More...
 
 load ($key)
 Load data from the cache using a given key. More...
 
 delete ($key)
 Invalidate a key. More...
 
 clear ()
 Clear out all the contents of the cache. More...
 
 invalidate ()
 Invalidate the contents of the cache. More...
 
 purge ()
 Purge old/stale contents of the cache. More...
 
 disable ()
 Disable cache Do not write or read from cache. More...
 
 enable ()
 Enable disabled cache. More...
 
 populate (array $values, int $expires_after=null)
 Populate cache from an array of key => values. More...
 
 add (string $key, $data)
 Add a key only if it doesn't already exist. More...
 
 offsetSet ($offset, $value)
 Assigns a value for the specified key. More...
 
 offsetGet ($offset)
 Get the value for specified key. More...
 
 offsetUnset ($offset)
 Unsets a key. More...
 
 offsetExists ($offset)
 Does key exist. More...
 

Static Public Member Functions

static isMemcacheAvailable ()
 Helper function to check if memcache is available. More...
 
static isRedisAvailable ()
 Helper function to check if Redis is available. More...
 

Public Attributes

const CACHE_BLACK_HOLE = 1
 
const CACHE_RUNTIME = 2
 
const CACHE_FILESYSTEM = 4
 
const CACHE_PERSISTENT = 8
 
const CACHE_LOCALFILESYSTEM = 32
 

Protected Member Functions

 prefixInstanceId (string $id)
 Prefixes instance ids with namespace. More...
 
 sanitizeItemKey ($key)
 Sanitizes item key for cache. More...
 
 createPool ()
 Create a new cluster/pool of drivers. More...
 
 buildRedisDriver ()
 Builds Redis driver. More...
 
 buildMemcachedDriver ()
 Builds Memcached driver. More...
 
 buildFileSystemDriver ()
 Builds file system driver. More...
 
 buildLocalFileSystemDriver ()
 Builds local file system driver. More...
 
 buildEphemeralDriver ()
 Builds in-memory driver. More...
 
 buildBlackHoleDriver ()
 Builds null cache driver. More...
 

Protected Attributes

int $ttl = 86400
 TTL of saved items (default timeout after a day to prevent anything getting too stale) More...
 
 $pool
 
- Protected Attributes inherited from Elgg\Cache\BaseCache
bool $disabled = false
 

Detailed Description

Composite cache pool.

Definition at line 20 of file CompositeCache.php.

Constructor & Destructor Documentation

Elgg\Cache\CompositeCache::__construct ( protected string  $namespace,
protected Config  $config,
protected int  $flags,
protected bool  $validate_lastcache = true 
)

Constructor.

Parameters
string$namespaceCache namespace
Config$configElgg config
int$flagsStart flags
bool$validate_lastcacheDuring load validate ElggConfig::lastcache

Definition at line 46 of file CompositeCache.php.

Member Function Documentation

Elgg\Cache\CompositeCache::buildBlackHoleDriver ( )
protected

Builds null cache driver.

Returns
null|ExtendedCacheItemPoolInterface

Definition at line 362 of file CompositeCache.php.

Elgg\Cache\CompositeCache::buildEphemeralDriver ( )
protected

Builds in-memory driver.

Returns
null|ExtendedCacheItemPoolInterface

Definition at line 345 of file CompositeCache.php.

Elgg\Cache\CompositeCache::buildFileSystemDriver ( )
protected

Builds file system driver.

Returns
null|ExtendedCacheItemPoolInterface

Definition at line 295 of file CompositeCache.php.

Elgg\Cache\CompositeCache::buildLocalFileSystemDriver ( )
protected

Builds local file system driver.

Returns
null|ExtendedCacheItemPoolInterface

Definition at line 320 of file CompositeCache.php.

Elgg\Cache\CompositeCache::buildMemcachedDriver ( )
protected

Builds Memcached driver.

Returns
null|ExtendedCacheItemPoolInterface

Definition at line 274 of file CompositeCache.php.

Elgg\Cache\CompositeCache::buildRedisDriver ( )
protected

Builds Redis driver.

Returns
null|ExtendedCacheItemPoolInterface

Definition at line 253 of file CompositeCache.php.

Elgg\Cache\CompositeCache::clear ( )

{}

Definition at line 127 of file CompositeCache.php.

Elgg\Cache\CompositeCache::createPool ( )
protected

Create a new cluster/pool of drivers.

Returns
ExtendedCacheItemPoolInterface
Exceptions
ConfigurationException

Definition at line 208 of file CompositeCache.php.

Elgg\Cache\CompositeCache::delete (   $key)

{}

Definition at line 116 of file CompositeCache.php.

Elgg\Cache\CompositeCache::getNamespace ( )

Get the namespace currently defined.

Returns
string

Definition at line 166 of file CompositeCache.php.

Elgg\Cache\CompositeCache::invalidate ( )

{}

Definition at line 134 of file CompositeCache.php.

static Elgg\Cache\CompositeCache::isMemcacheAvailable ( )
static

Helper function to check if memcache is available.

Returns
bool
Since
4.2

Definition at line 379 of file CompositeCache.php.

static Elgg\Cache\CompositeCache::isRedisAvailable ( )
static

Helper function to check if Redis is available.

Returns
bool
Since
4.2

Definition at line 390 of file CompositeCache.php.

Elgg\Cache\CompositeCache::load (   $key)

Load data from the cache using a given key.

Parameters
string$keyName
Returns
mixed The stored data or false.

Definition at line 85 of file CompositeCache.php.

Elgg\Cache\CompositeCache::prefixInstanceId ( string  $id)
protected

Prefixes instance ids with namespace.

Parameters
string$idinstance id
Returns
string
Since
4.2

Definition at line 179 of file CompositeCache.php.

Elgg\Cache\CompositeCache::purge ( )

{}

Definition at line 143 of file CompositeCache.php.

Elgg\Cache\CompositeCache::sanitizeItemKey (   $key)
protected

Sanitizes item key for cache.

Parameters
mixed$keyinput key
Returns
string
Exceptions
InvalidArgumentException
Since
4.2

Definition at line 194 of file CompositeCache.php.

Elgg\Cache\CompositeCache::save (   $key,
  $data,
  $expire_after = null 
)

Save data in a cache.

Parameters
string$keyName
mixed$dataValue
int | \DateTime$expire_afterExpire value after
Returns
bool

Definition at line 59 of file CompositeCache.php.

Elgg\Cache\CompositeCache::setNamespace (   $namespace = 'default')

Set the namespace of this cache.

This is useful for cache types (like memcache or static variables) where there is one large flat area of memory shared across all instances of the cache.

Parameters
string$namespaceNamespace for cache
Returns
void

Definition at line 157 of file CompositeCache.php.

Member Data Documentation

Elgg\Cache\CompositeCache::$pool
protected

Definition at line 36 of file CompositeCache.php.

int Elgg\Cache\CompositeCache::$ttl = 86400
protected

TTL of saved items (default timeout after a day to prevent anything getting too stale)

Definition at line 31 of file CompositeCache.php.

const Elgg\Cache\CompositeCache::CACHE_BLACK_HOLE = 1

Definition at line 22 of file CompositeCache.php.

const Elgg\Cache\CompositeCache::CACHE_FILESYSTEM = 4

Definition at line 24 of file CompositeCache.php.

const Elgg\Cache\CompositeCache::CACHE_LOCALFILESYSTEM = 32

Definition at line 26 of file CompositeCache.php.

const Elgg\Cache\CompositeCache::CACHE_PERSISTENT = 8

Definition at line 25 of file CompositeCache.php.

const Elgg\Cache\CompositeCache::CACHE_RUNTIME = 2

Definition at line 23 of file CompositeCache.php.


The documentation for this class was generated from the following file: