PHP Interface Stash\Interfaces\ItemInterface

Inheritance: extends Psr\Cache\CacheItemInterface
Mostra file Open project: tedivm/stash Interface Usage Examples

Public Methods

Method Description
clear ( ) : boolean Clears the current Item. If hierarchical or "stackable" caching is being used this function will also remove children Items.
disable ( ) : boolean This disables any IO operations by this object, effectively preventing the reading and writing of new data.
expiresAfter ( integer | DateInterval $time ) : self Sets the expiration based off of an integer or DateInterval
expiresAt ( DateTimeInterface $expiration ) : self Sets the expiration to a specific time.
extend ( null $ttl = null ) : boolean Extends the expiration on the current cached item. For some engines this can be faster than storing the item again.
get ( ) : mixed Returns the data retrieved from the cache. Since this can return false or null as a correctly cached value, the return value should not be used to determine successful retrieval of data- for that use the "isMiss()" function after call this one. If no value is stored at all then this function will return null.
getCreation ( ) : DateTime Returns the record's creation time or false if it isn't set
getExpiration ( ) : DateTime Returns the record's expiration timestamp or false if no expiration timestamp is set
getKey ( ) : string Returns the key as a string. This is particularly useful when the Item is returned as a group of Items in an Iterator.
isDisabled ( ) : boolean Return true if caching is disabled
isHit ( ) : boolean Returns true if the cached item is valid and usable.
isMiss ( ) : boolean Returns true if the cached item needs to be refreshed.
lock ( null $ttl = null ) : boolean Enables stampede protection by marking this specific instance of the Item as the one regenerating the cache.
save ( ) : boolean Persists the Item's value to the backend storage.
set ( mixed $value ) : self Takes and stores data for later retrieval. This data can be any php data, including arrays and object, except resources and objects which are unable to be serialized.
setInvalidationMethod ( integer $invalidation, mixed $arg = null, mixed $arg2 = null ) Set the cache invalidation method for this item.
setKey ( array $key, string | null $namespace = null ) Takes and sets the key and namespace.
setLogger ( PSR\Log\LoggerInterface $logger ) : boolean Sets a PSR\Logger style logging client to enable the tracking of errors.
setPool ( Stash\Interfaces\PoolInterface $driver ) Sets the Parent Pool for the Item class to use.
setTTL ( mixed $ttl = null ) : self Sets the expiration based off a an integer, date interval, or date

Method Details

clear() public method

Clears the current Item. If hierarchical or "stackable" caching is being used this function will also remove children Items.
public clear ( ) : boolean
return boolean

disable() public method

This disables any IO operations by this object, effectively preventing the reading and writing of new data.
public disable ( ) : boolean
return boolean

expiresAfter() public method

Sets the expiration based off of an integer or DateInterval
public expiresAfter ( integer | DateInterval $time ) : self
$time integer | DateInterval
return self

expiresAt() public method

Sets the expiration to a specific time.
public expiresAt ( DateTimeInterface $expiration ) : self
$expiration DateTimeInterface
return self

extend() public method

Extends the expiration on the current cached item. For some engines this can be faster than storing the item again.
public extend ( null $ttl = null ) : boolean
$ttl null
return boolean

get() public method

Returns the data retrieved from the cache. Since this can return false or null as a correctly cached value, the return value should not be used to determine successful retrieval of data- for that use the "isMiss()" function after call this one. If no value is stored at all then this function will return null.
public get ( ) : mixed
return mixed

getCreation() public method

Returns the record's creation time or false if it isn't set
public getCreation ( ) : DateTime
return DateTime

getExpiration() public method

Returns the record's expiration timestamp or false if no expiration timestamp is set
public getExpiration ( ) : DateTime
return DateTime

getKey() public method

Returns the key as a string. This is particularly useful when the Item is returned as a group of Items in an Iterator.
public getKey ( ) : string
return string

isDisabled() public method

Return true if caching is disabled
public isDisabled ( ) : boolean
return boolean True if caching is disabled.

isHit() public method

Returns true if the cached item is valid and usable.
public isHit ( ) : boolean
return boolean

isMiss() public method

Returns true if the cached item needs to be refreshed.
public isMiss ( ) : boolean
return boolean

lock() public method

Enables stampede protection by marking this specific instance of the Item as the one regenerating the cache.
public lock ( null $ttl = null ) : boolean
$ttl null
return boolean

save() public method

Persists the Item's value to the backend storage.
public save ( ) : boolean
return boolean

set() public method

Takes and stores data for later retrieval. This data can be any php data, including arrays and object, except resources and objects which are unable to be serialized.
public set ( mixed $value ) : self
$value mixed bool
return self

setInvalidationMethod() public method

Set the cache invalidation method for this item.
See also: Stash\Invalidation
public setInvalidationMethod ( integer $invalidation, mixed $arg = null, mixed $arg2 = null )
$invalidation integer A Stash\Invalidation constant
$arg mixed First argument for invalidation method
$arg2 mixed Second argument for invalidation method

setKey() public method

Typically called by Pool directly, and *must* be called before running caching functions.
public setKey ( array $key, string | null $namespace = null )
$key array
$namespace string | null

setLogger() public method

Sets a PSR\Logger style logging client to enable the tracking of errors.
public setLogger ( PSR\Log\LoggerInterface $logger ) : boolean
$logger PSR\Log\LoggerInterface
return boolean

setPool() public method

Typically called by Pool directly, and *must* be called before running caching functions.
public setPool ( Stash\Interfaces\PoolInterface $driver )
$driver Stash\Interfaces\PoolInterface

setTTL() public method

Sets the expiration based off a an integer, date interval, or date
public setTTL ( mixed $ttl = null ) : self
$ttl mixed An integer, date interval, or date
return self