PHP Class Stash\Item

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

Méthodes publiques

Свойство 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

Свойство 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.

Méthodes publiques

Méthode 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 )

Méthodes protégées

Méthode 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

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

Method Details

__destruct() public méthode

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

clear() public méthode

public clear ( )

disable() public méthode

public disable ( )

expiresAfter() public méthode

public expiresAfter ( $time )

expiresAt() public méthode

public expiresAt ( $expiration = null )

extend() public méthode

public extend ( $ttl = null )

get() public méthode

public get ( )

getCreation() public méthode

public getCreation ( )

getExpiration() public méthode

public getExpiration ( )

getKey() public méthode

public getKey ( )

getRecord() protected méthode

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

getStampedeFlag() protected méthode

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

isDisabled() public méthode

public isDisabled ( )

isHit() public méthode

public isHit ( )

isMiss() public méthode

public isMiss ( )

lock() public méthode

public lock ( $ttl = null )

logException() protected méthode

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

save() public méthode

public save ( )

set() public méthode

public set ( $value )

setInvalidationMethod() public méthode

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

setKey() public méthode

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

setLogger() public méthode

public setLogger ( $logger )

setPool() public méthode

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

setTTL() public méthode

public setTTL ( $ttl = null )

validateRecord() protected méthode

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
Résultat 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
Résultat 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
Résultat 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
Résultat 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
Résultat Psr\Log\LoggerInterface

$namespace protected_oe property

Defines the namespace the item lives in.
protected string|null $namespace
Résultat string | null

$pool protected_oe property

.
protected PoolInterface,Stash\Interfaces $pool
Résultat 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
Résultat boolean

$stampedeRunning protected_oe property

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