Stud.IP  5.4
StudipCachedArray Class Reference
Inheritance diagram for StudipCachedArray:

Public Member Functions

 __construct (string $key, int $duration=StudipCache::DEFAULT_EXPIRATION)
 
 reset ()
 
 expire ()
 
 offsetExists ($offset)
 
 offsetGet ($offset)
 
 offsetSet ($offset, $value)
 
 offsetUnset ($offset)
 

Protected Member Functions

 loadData (string $offset)
 
 storeData (string $offset)
 

Protected Attributes

 $key
 
 $cache
 
 $duration
 
 $data = []
 
 $hash
 

Detailed Description

This class represents an array in cache and removes the neccessity to encode/decode and store the data after every change.

Author
Jan-Hendrik Willms tleil.nosp@m.ax+s.nosp@m.tudip.nosp@m.@gma.nosp@m.il.co.nosp@m.m GPL2 or any later version
Since
Stud.IP 5.0

Constructor & Destructor Documentation

◆ __construct()

__construct ( string  $key,
int  $duration = StudipCache::DEFAULT_EXPIRATION 
)

Constructs the cached array

Parameters
string$keyCache key where the array is/should be stored an int which will be length of the substring of the given chache offset or a callable which will return the partition key.
int$durationDuration in seconds for which the item shall be stored

Member Function Documentation

◆ expire()

expire ( )

Removes all values from the cache.

◆ loadData()

loadData ( string  $offset)
protected

Loads the data from cache.

Parameters
string$offsetOffset to load

◆ offsetExists()

offsetExists (   $offset)

Determines whether an offset exists in the array.

Parameters
string$offsetOffset
Returns
bool

◆ offsetGet()

offsetGet (   $offset)

Returns the value at given offset or null if it doesn't exist.

Parameters
string$offsetOffset
Returns
mixed

◆ offsetSet()

offsetSet (   $offset,
  $value 
)

Sets the value for a given offset.

Parameters
string$offsetOffset
mixed$valueValue

◆ offsetUnset()

offsetUnset (   $offset)

Unsets the value at a given offset

Parameters
string$offsetOffset

◆ reset()

reset ( )

Clears cached values from memory, but does not remove them from the cache.

◆ storeData()

storeData ( string  $offset)
protected

Stores the data back to the cache. Data needs to be wrapped in another array so that we can correctly read back a value of "false".

Parameters
string$offsetOffset to store

Field Documentation

◆ $cache

$cache
protected

◆ $data

$data = []
protected

◆ $duration

$duration
protected

◆ $hash

$hash
protected

◆ $key

$key
protected

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