Scrapbook

Item
in package
implements CacheItemInterface

Representation of a cache item, both existing & non-existing (to be created).

Tags
author

Matthias Mullie [email protected]

copyright

Copyright (c) 2014, Matthias Mullie. All rights reserved

license

LICENSE MIT

Table of Contents

Interfaces

CacheItemInterface
CacheItemInterface defines an interface for interacting with objects inside a cache.

Methods

__construct()  : mixed
__destruct()  : mixed
When this item is being killed, we should no longer keep its value around in the repository. Free up some memory!
expiresAfter()  : static
Sets the expiration time for this cache item.
expiresAt()  : static
Sets the expiration time for this cache item.
get()  : mixed
Retrieves the value of the item from the cache associated with this object's key.
getExpiration()  : int
Returns the set expiration time in integer form (as it's what KeyValueStore expects).
getKey()  : string
Returns the key for the current cache item.
hasChanged()  : bool
We'll want to know if this Item was altered (value or expiration date) once we'll want to store it.
isExpired()  : bool
Returns true if the item is already expired, false otherwise.
isHit()  : bool
Confirms if the cache item lookup resulted in a cache hit.
overrideIsHit()  : void
Allow isHit to be override, in case it's a value that is returned from memory, when a value is being saved deferred.
set()  : static
Sets the value represented by this cache item.

Methods

__construct()

public __construct(string $key, Repository $repository) : mixed
Parameters
$key : string
$repository : Repository

__destruct()

When this item is being killed, we should no longer keep its value around in the repository. Free up some memory!

public __destruct() : mixed

expiresAfter()

Sets the expiration time for this cache item.

public expiresAfter(int|DateInterval|null $time) : static
Parameters
$time : int|DateInterval|null

The period of time from the present after which the item MUST be considered expired. An integer parameter is understood to be the time in seconds until expiration. If null is passed explicitly, a default value MAY be used. If none is set, the value should be stored permanently or for as long as the implementation allows.

Return values
static

The called object.

expiresAt()

Sets the expiration time for this cache item.

public expiresAt(DateTimeInterface|null $expiration) : static
Parameters
$expiration : DateTimeInterface|null

The point in time after which the item MUST be considered expired. If null is passed explicitly, a default value MAY be used. If none is set, the value should be stored permanently or for as long as the implementation allows.

Return values
static

The called object.

get()

Retrieves the value of the item from the cache associated with this object's key.

public get() : mixed

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."

Return values
mixed

The value corresponding to this cache item's key, or null if not found.

getExpiration()

Returns the set expiration time in integer form (as it's what KeyValueStore expects).

public getExpiration() : int
Return values
int

getKey()

Returns the key for the current cache item.

public getKey() : string

The key is loaded by the Implementing Library, but should be available to the higher level callers when needed.

Return values
string

The key string for this cache item.

hasChanged()

We'll want to know if this Item was altered (value or expiration date) once we'll want to store it.

public hasChanged() : bool
Return values
bool

isExpired()

Returns true if the item is already expired, false otherwise.

public isExpired() : bool
Return values
bool

isHit()

Confirms if the cache item lookup resulted in a cache hit.

public isHit() : bool

Note: This method MUST NOT have a race condition between calling isHit() and calling get().

Return values
bool

True if the request resulted in a cache hit. False otherwise.

overrideIsHit()

Allow isHit to be override, in case it's a value that is returned from memory, when a value is being saved deferred.

public overrideIsHit(bool $isHit) : void
Parameters
$isHit : bool

set()

Sets the value represented by this cache item.

public set(mixed $value) : static

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.

Parameters
$value : mixed

The serializable value to be stored.

Return values
static

The invoked object.


        
On this page

Search results