Stud.IP  6.0
Item Class Reference
Inheritance diagram for Item:

Public Member Functions

 __construct (string $key, mixed $value=null, ?int $expiration=null, bool $cache_hit=false)
 
 getKey ()
 
 get ()
 
 isHit ()
 
 set ($value)
 
 expiresAt ($expiration)
 
 expiresAfter ($time)
 
 setHit ()
 
 getExpiration ()
 
 getExpirationInSeconds ()
 

Protected Attributes

string $key
 
mixed $value
 
DateTime $expiration = null
 
bool $cache_hit = false
 

Detailed Description

implements the CacheItemInterface of PSR-6. It holds the value and the key of a cache item and also provides additional methods to get the expiration of the item.

Constructor & Destructor Documentation

◆ __construct()

__construct ( string  $key,
mixed  $value = null,
?int  $expiration = null,
bool  $cache_hit = false 
)

The constructor of .

Parameters
string$keyThe key of the item in the cache.
mixed$valueThe value of the item.
int | null$expirationThe expiration of the item in seconds, if applicable.
bool$cache_hitWhether the item shall be constructed as cache hit (true) or not (false).

Member Function Documentation

◆ expiresAfter()

expiresAfter (   $time)

◆ expiresAt()

expiresAt (   $expiration)

◆ get()

get ( )

◆ getExpiration()

getExpiration ( )

Returns the expiration, if set.

Returns
DateTime|null A DateTime object with the expiration date and time or null if the expiration is not defined.

◆ getExpirationInSeconds()

getExpirationInSeconds ( )

Returns the seconds from the current timestamp until the expiration of the item.

Returns
int The seconds until the item expires

◆ getKey()

getKey ( )

◆ isHit()

isHit ( )

◆ set()

set (   $value)

◆ setHit()

setHit ( )

Sets the item to be a cache hit.

Returns
void

Field Documentation

◆ $cache_hit

bool $cache_hit = false
protected

◆ $expiration

DateTime $expiration = null
protected

◆ $key

string $key
protected

◆ $value

mixed $value
protected

The documentation for this class was generated from the following file: