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 = [])

Internal logging helper.

Details

at line 40
getKey()

{@inheritdoc}

at line 48
get()

{@inheritdoc}

at line 56
isHit()

{@inheritdoc}

at line 64
set($value)

{@inheritdoc}

Parameters

$value

at line 74
expiresAt($expiration)

{@inheritdoc}

Parameters

$expiration

at line 90
expiresAfter($time)

{@inheritdoc}

Parameters

$time

at line 108
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

at line 138
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

at line 150
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

at line 166
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

at line 186
static log(LoggerInterface $logger = null, $message, $context = [])

Internal logging helper.

Parameters

LoggerInterface $logger
$message
$context