PHP Class Stash\Item

Author: Robert Hafner ([email protected])
Inheritance: implements Stash\Interfaces\ItemInterface
Datei anzeigen Open project: tedivm/stash Class Usage Examples

Public Properties

Property Type Description
$cacheTime This is the default time, in seconds, that objects are cached for.
$runtimeDisable boolean Disables the cache system wide. It is used internally when the storage engine fails or if the cache is being cleared. This differs from the cacheEnabled property in that it affects all instances of the cache, not just one.

Protected Properties

Property Type Description
$cacheEnabled boolean Used internally to mark the class as disabled. Unlike the static runtimeDisable flag this is effective only for the current instance.
$data
$defaults array Contains a list of default arguments for when users do not supply them.
$driver Stash\Interfaces\DriverInterface The cacheDriver being used by the system. While this class handles all of the higher functions, it's the cache driver here that handles all of the storage/retrieval functionality. This value is set by the constructor.
$expiration
$invalidationArg1
$invalidationArg2
$invalidationMethod
$key The identifier for the item being cached. It is set through the setupKey function.
$keyString string A serialized version of the key, used primarily used as the index in various arrays.
$logger Psr\Log\LoggerInterface If set various then errors and exceptions will get passed to the PSR Compliant logging library. This can be set using the setLogger() function in this class.
$namespace string | null Defines the namespace the item lives in.
$pool Stash\Interfaces\PoolInterface .
$stampedeRunning boolean Marks whether or not stampede protection is enabled for this instance of Stash.

Public Methods

Method Description
__destruct ( ) This clears out any locks that are present if this Item is prematurely destructed.
clear ( )
disable ( )
expiresAfter ( $time )
expiresAt ( $expiration = null )
extend ( $ttl = null )
get ( )
getCreation ( )
getExpiration ( )
getKey ( )
isDisabled ( )
isHit ( )
isMiss ( )
lock ( $ttl = null )
save ( )
set ( $value )
setInvalidationMethod ( $invalidation = Invalidation::PRECOMPUTE, $arg = null, $arg2 = null )
setKey ( array $key, $namespace = null )
setLogger ( $logger )
setPool ( Stash\Interfaces\PoolInterface $pool )
setTTL ( $ttl = null )

Protected Methods

Method Description
getRecord ( ) : array Returns the record for the current key. If there is no record than an empty array is returned.
getStampedeFlag ( array $key ) : boolean Returns true if another Item is currently recalculating the cache.
logException ( string $message, Exception $exception ) : boolean Logs an exception with the Logger class, if it exists.
validateRecord ( array $validation, &$record ) Decides whether the current data is fresh according to the supplied validation technique. As some techniques actively change the record this function takes that in as a reference.

Private Methods

Method Description
executeClear ( )
executeGet ( $invalidation = Invalidation::PRECOMPUTE, $arg = null, $arg2 = null )
executeSet ( $data, $time )

Method Details

__destruct() public method

This clears out any locks that are present if this Item is prematurely destructed.
public __destruct ( )

clear() public method

public clear ( )

disable() public method

public disable ( )

expiresAfter() public method

public expiresAfter ( $time )

expiresAt() public method

public expiresAt ( $expiration = null )

extend() public method

public extend ( $ttl = null )

get() public method

public get ( )

getCreation() public method

public getCreation ( )

getExpiration() public method

public getExpiration ( )

getKey() public method

public getKey ( )

getRecord() protected method

Returns the record for the current key. If there is no record than an empty array is returned.
protected getRecord ( ) : array
return array

getStampedeFlag() protected method

Returns true if another Item is currently recalculating the cache.
protected getStampedeFlag ( array $key ) : boolean
$key array
return boolean

isDisabled() public method

public isDisabled ( )

isHit() public method

public isHit ( )

isMiss() public method

public isMiss ( )

lock() public method

public lock ( $ttl = null )

logException() protected method

Logs an exception with the Logger class, if it exists.
protected logException ( string $message, Exception $exception ) : boolean
$message string
$exception Exception
return boolean

save() public method

public save ( )

set() public method

public set ( $value )

setInvalidationMethod() public method

public setInvalidationMethod ( $invalidation = Invalidation::PRECOMPUTE, $arg = null, $arg2 = null )

setKey() public method

public setKey ( array $key, $namespace = null )
$key array

setLogger() public method

public setLogger ( $logger )

setPool() public method

public setPool ( Stash\Interfaces\PoolInterface $pool )
$pool Stash\Interfaces\PoolInterface

setTTL() public method

public setTTL ( $ttl = null )

validateRecord() protected method

This function has the ability to change the isHit property as well as the record passed.
protected validateRecord ( array $validation, &$record )
$validation array

Property Details

$cacheEnabled protected_oe property

Used internally to mark the class as disabled. Unlike the static runtimeDisable flag this is effective only for the current instance.
protected bool $cacheEnabled
return boolean

$cacheTime public_oe static_oe property

This is the default time, in seconds, that objects are cached for.
public static $cacheTime

$data protected_oe property

protected $data

$defaults protected_oe property

Contains a list of default arguments for when users do not supply them.
protected array $defaults
return array

$driver protected_oe property

The cacheDriver being used by the system. While this class handles all of the higher functions, it's the cache driver here that handles all of the storage/retrieval functionality. This value is set by the constructor.
protected DriverInterface,Stash\Interfaces $driver
return Stash\Interfaces\DriverInterface

$expiration protected_oe property

protected $expiration

$invalidationArg1 protected_oe property

protected $invalidationArg1

$invalidationArg2 protected_oe property

protected $invalidationArg2

$invalidationMethod protected_oe property

protected $invalidationMethod

$key protected_oe property

The identifier for the item being cached. It is set through the setupKey function.
protected $key

$keyString protected_oe property

A serialized version of the key, used primarily used as the index in various arrays.
protected string $keyString
return string

$logger protected_oe property

If set various then errors and exceptions will get passed to the PSR Compliant logging library. This can be set using the setLogger() function in this class.
protected LoggerInterface,Psr\Log $logger
return Psr\Log\LoggerInterface

$namespace protected_oe property

Defines the namespace the item lives in.
protected string|null $namespace
return string | null

$pool protected_oe property

.
protected PoolInterface,Stash\Interfaces $pool
return Stash\Interfaces\PoolInterface

$runtimeDisable public_oe static_oe property

Disables the cache system wide. It is used internally when the storage engine fails or if the cache is being cleared. This differs from the cacheEnabled property in that it affects all instances of the cache, not just one.
public static bool $runtimeDisable
return boolean

$stampedeRunning protected_oe property

Marks whether or not stampede protection is enabled for this instance of Stash.
protected bool $stampedeRunning
return boolean