CacheItem
final class CacheItem implements CacheItemInterface (View source)
Holds one PSR-6 cache value together with its original hit state and optional expiration.
Value and expiration are mutable as required by PSR-6, while key and hit origin remain fixed.
Methods
Captures the key, value, lookup result, and optional absolute expiration.
Returns the immutable key associated with this item.
Returns the value currently held by this item.
Reports a hit only when the item originated as one and has not expired.
Sets an absolute expiration using an immutable copy, or clears it with null.
Sets expiration relative to now, clamps negative seconds to zero, or clears it with null.
Exposes the normalized absolute expiration used by framework pool implementations.
Details
__construct
__construct(string $key, mixed $value = null, bool $hit = false, DateTimeImmutable|null $expiresAt = null)
Captures the key, value, lookup result, and optional absolute expiration.
getKey
string
getKey()
Returns the immutable key associated with this item.
get
mixed
get()
Returns the value currently held by this item.
isHit
bool
isHit()
Reports a hit only when the item originated as one and has not expired.
expiresAt
CacheItem
expiresAt(DateTimeInterface|null $expiration)
Sets an absolute expiration using an immutable copy, or clears it with null.
expiresAfter
CacheItem
expiresAfter(DateInterval|int|null $time)
Sets expiration relative to now, clamps negative seconds to zero, or clears it with null.
expiresAtDate
DateTimeImmutable|null
expiresAtDate()
Exposes the normalized absolute expiration used by framework pool implementations.