class CacheItem implements ItemInterface

Constants

METADATA_EXPIRY_OFFSET

Properties

protected $key
protected $value
protected $isHit
protected $expiry
protected $defaultLifetime
protected $metadata
protected $newMetadata
protected $innerItem
protected $poolHash
protected $isTaggable

Methods

getKey()

{@inheritdoc}

get()

{@inheritdoc}

isHit()

{@inheritdoc}

set($value)

{@inheritdoc}

expiresAt($expiration)

{@inheritdoc}

expiresAfter($time)

{@inheritdoc}

tag(string|string[] $tags)

Adds a tag to a cache item.

array
getMetadata()

Returns a list of metadata info that were saved alongside with the cached value.

array
getPreviousTags() deprecated

Returns the list of tags bound to the value coming from the pool storage if any.

static string
validateKey(string $key)

Validates a cache key according to PSR-6.

static 
log(LoggerInterface $logger = null, $message, $context = array())

Internal logging helper.

Details

getKey()

{@inheritdoc}

get()

{@inheritdoc}

isHit()

{@inheritdoc}

set($value)

{@inheritdoc}

Parameters

$value

expiresAt($expiration)

{@inheritdoc}

Parameters

$expiration

expiresAfter($time)

{@inheritdoc}

Parameters

$time

ItemInterface tag(string|string[] $tags)

Adds a tag to a cache item.

Tags are strings that follow the same validation rules as keys.

Parameters

string|string[] $tags A tag or array of tags

Return Value

ItemInterface

Exceptions

InvalidArgumentException When $tag is not valid
CacheException When the item comes from a pool that is not tag-aware

array getMetadata()

Returns a list of metadata info that were saved alongside with the cached value.

See ItemInterface::METADATA_* consts for keys potentially found in the returned array.

Return Value

array

array getPreviousTags() deprecated

deprecated since Symfony 4.2, use the "getMetadata()" method instead.

Returns the list of tags bound to the value coming from the pool storage if any.

Return Value

array

static string validateKey(string $key)

Validates a cache key according to PSR-6.

Parameters

string $key The key to validate

Return Value

string

Exceptions

InvalidArgumentException When $key is not valid

static log(LoggerInterface $logger = null, $message, $context = array())

Internal logging helper.

Parameters

LoggerInterface $logger
$message
$context