Class Cache
Provides a cache for arbitrary data and driver-based storage. Cache entries are identified by a class and key that together form a unique hash. Additionally, a timestamp is stored with each entry and optionally a maximum age, after which entries are deleted.
To avoid corrupt data, cache entries are stored with the version ID of the cache instance (defaults to the framework revision). A version ID must match for a cache entry to be fetched. After upgrading a system, it is recommended to clean up old cache entries if no older version of the system is still running.
A default cache instance is transparently used by system functions. This
can either be configured via the Core\Configuration\CacheFilesTarget
configuration constant or an existing driver instance can be set as default
via Core\Cache::activate()
.
- Core\Object implements Core\Chainable
- Core\Set implements Core\Accessor
- Core\Cache
Direct known subclasses
Core\Cache\Driver\apc
,
Core\Cache\Driver\file
,
Core\Cache\Driver\null
,
Core\Cache\Driver\storage
Namespace: Core
Package: Core\Cache
Since: 3.0
Requires: PHP 5.3
Version: 1.2
Located at Cache.inc.php
Methods summary
public
|
|
public static
|
|
public static
|
#
active( )
Returns the currently active cache instance. If no cache instance is active, the default instance is activated and returned. |
public static
|
|
public static
|
#
defaultInstance( )
Returns the default cache instance. The default cache instance is
configured by defining several cache targets using the
|
abstract public
boolean
|
|
public
string
|
|
public
integer
|
|
public
string
|
#
getHash( string $class, string $key )
Returns the hash for the requested cache entry. The hash type depends on the backend in use and defaults to 16-byte binary MD5. |
public
array
|
#
getMeta( string $class, string $key )
Returns an array of meta attributes for the requested cache entry. |
abstract public
|
#
getStream( string $class, string $key )
Returns a reading stream instance for the requested cache entry. |
abstract public
integer
|
#
getTimestamp( string $class, string $key )
Returns a UNIX timestamp of the last cache entry modification. |
public
mixed
|
|
public
|
#
put( string $class, string $key, string $binaryData, integer $ttl = null )
Writes binary data to a specified cache entry. |
abstract public
|
#
putStream( string $class, string $key, integer $ttl = null )
Returns a writing stream instance for the requested cache entry. |
public
|
#
putVar( string $class, string $key, mixed $value, integer $ttl = null )
Writes a variable serialized to a specified cache entry. |
abstract public
|
#
remove( string $class, string $key )
Deletes a cache key entry. If the entry does not exist, no operation is performed. |
public
integer
|
#
setVersionID( integer $versionID )
Sets the automatically appended numeric subclass for data entries. |
public static
string
|
Methods inherited from Core\Object
__autocreateFactory()
,
__call()
,
__processParameters()
,
__toString()
,
attachMethod()
,
chain()
,
getValueForKey()
,
getValueForKeyPath()
,
getValueForUndefinedKey()
,
hash()
,
issetValueForKey()
,
setValueForKey()
,
setValueForKeyPath()
,
setValueForUndefinedKey()
,
uuid()
Constants summary
string |
SharedClass
Predefined name of shared cache class. |
#
'Shared'
|
Constants inherited from Core\Object
AnyParameterType
,
AutochainParameterType
,
AutocreateParameterType
,
BooleanParameterType
,
CharParameterType
,
EnumParameterType
,
IntegerParameterType
,
RealParameterType
,
StringParameterType
,
UserParameterType
Properties summary
public static
|
$_activeInstance
Activated default cache instance. |
|
protected
integer
|
$_v_versionID
Version ID of cache entries. |
Magic properties
public read-only
integer
|
$versionID
Configured version ID cache entries are assigned to. |