Item
class Item implements CacheItemInterface (View source)
A cache item.
This class will be used by MemoryCacheItemPool and SysVCacheItemPool on PHP 7.4 and below. It is compatible with psr/cache 1.0 and 2.0 (PSR-6).
Methods
No description
Returns the key for the current cache item.
Retrieves the value of the item from the cache associated with this object's key.
Confirms if the cache item lookup resulted in a cache hit.
Sets the value represented by this cache item.
No description
Details
at line 58
__construct(string $key)
at line 66
string
getKey()
Returns the key for the current cache item.
The key is loaded by the Implementing Library, but should be available to the higher level callers when needed.
at line 74
mixed
get()
Retrieves the value of the item from the cache associated with this object's key.
The value returned must be identical to the value originally stored by set().
If isHit() returns false, this method MUST return null. Note that null is a legitimate cached value, so the isHit() method SHOULD be used to differentiate between "null value was found" and "no value was found."
at line 82
bool
isHit()
Confirms if the cache item lookup resulted in a cache hit.
Note: This method MUST NOT have a race condition between calling isHit() and calling get().
at line 98
CacheItemInterface
set(mixed $value)
Sets the value represented by this cache item.
The $value argument may be any item that can be serialized by PHP, although the method of serialization is left up to the Implementing Library.
at line 109
CacheItemInterface
expiresAt(DateTimeInterface|null $expiration)
Sets the expiration time for this cache item.
at line 129
CacheItemInterface
expiresAfter(int|DateInterval|null $time)
Sets the expiration time for this cache item.