PHP Класс Cachearium\CacheData

Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
$data array The actual cached data
$dependencies array:CacheKey This is a storage of dependencies for this cache. This is stored here as the russian doll model will automatically push up dependencies. In the end this will probably be used by the storage for easy invalidation.
$key CacheKey
$lifetime integer Lifetime: how long this cache should live. It's up to the storage implementation the details of how this will be obeyed, if at all.

Открытые методы

Метод Описание
__construct ( CacheKey $ck, $data = null )
addDependencies ( array $deps ) : CacheData Adds a dependency
addDependency ( CacheKey $k ) : CacheData Adds a dependency
appendCallback ( callable $callback ) : CacheData
appendData ( mixed $data ) : CacheData
appendRecursion ( CacheKey $k )
appendRecursionData ( CacheData $d )
checkClash ( CacheKey $k ) : boolean Checks if a set of keys clashes with the ones used here.
checkUpdateToDate ( CacheAbstract $cache ) : boolean Checks if dependencies are still fresh.
clearDependenciesHash ( )
dependencyInit ( CacheAbstract $cache, CacheKey $k ) : integer Init dependencies. If increment is not supported by backend return 0.
generateDependenciesHash ( CacheAbstract $cache ) : string Get a fresh hash based on dependencies. Does not update the current hash.
getDependencies ( )
getDependenciesHash ( )
getFirstData ( ) : any | null Convenience function. Returns the first data self::CACHEDATA_TYPE_DATA that you stored. Returns null if there is none.
getKey ( )
mergeDependencies ( CacheData $cd ) : CacheData
serialize ( ) : string Serialize this object to a string so we can easily store.
setDependencies ( array $deps, CacheAbstract $cache ) : CacheData Sets the list of dependencies and updates the dependency hash
setKey ( CacheKey $ck ) : CacheData
setLifetime ( integer $lifetime ) : CacheData
stringify ( CacheAbstract $c, $recurse = true ) Converts this data to a string that can output. This is not a hash key or a serialization, but an actual render for humans.
unserialize ( string $data ) : CacheData Unserializes data and returns a new CacheData. This is what you should use to get the object data from the storage.
updateDependenciesHash ( CacheAbstract $cache )
updateDependenciesHashIfNull ( CacheAbstract $cache )

Описание методов

__construct() публичный Метод

public __construct ( CacheKey $ck, $data = null )
$ck CacheKey

addDependencies() публичный Метод

Adds a dependency
public addDependencies ( array $deps ) : CacheData
$deps array
Результат CacheData This

addDependency() публичный Метод

Adds a dependency
public addDependency ( CacheKey $k ) : CacheData
$k CacheKey
Результат CacheData This

appendCallback() публичный Метод

public appendCallback ( callable $callback ) : CacheData
$callback callable
Результат CacheData

appendData() публичный Метод

public appendData ( mixed $data ) : CacheData
$data mixed Any kind of data you want to store. usually strings.
Результат CacheData

appendRecursion() публичный Метод

public appendRecursion ( CacheKey $k )
$k CacheKey

appendRecursionData() публичный Метод

public appendRecursionData ( CacheData $d )
$d CacheData

checkClash() публичный Метод

Checks if a set of keys clashes with the ones used here.
public checkClash ( CacheKey $k ) : boolean
$k CacheKey
Результат boolean True if they match and there is a clash

checkUpdateToDate() публичный Метод

Checks if dependencies are still fresh.
public checkUpdateToDate ( CacheAbstract $cache ) : boolean
$cache CacheAbstract
Результат boolean

clearDependenciesHash() публичный Метод

dependencyInit() публичный Метод

Init dependencies. If increment is not supported by backend return 0.
public dependencyInit ( CacheAbstract $cache, CacheKey $k ) : integer
$cache CacheAbstract
$k CacheKey
Результат integer

generateDependenciesHash() публичный Метод

Get a fresh hash based on dependencies. Does not update the current hash.
public generateDependenciesHash ( CacheAbstract $cache ) : string
$cache CacheAbstract
Результат string

getDependencies() публичный Метод

public getDependencies ( )

getDependenciesHash() публичный Метод

public getDependenciesHash ( )

getFirstData() публичный Метод

Convenience function. Returns the first data self::CACHEDATA_TYPE_DATA that you stored. Returns null if there is none.
public getFirstData ( ) : any | null
Результат any | null

getKey() публичный Метод

public getKey ( )

mergeDependencies() публичный Метод

public mergeDependencies ( CacheData $cd ) : CacheData
$cd CacheData
Результат CacheData

serialize() публичный Метод

Serialize this object to a string so we can easily store.
public serialize ( ) : string
Результат string

setDependencies() публичный Метод

Sets the list of dependencies and updates the dependency hash
public setDependencies ( array $deps, CacheAbstract $cache ) : CacheData
$deps array
$cache CacheAbstract
Результат CacheData

setKey() публичный Метод

public setKey ( CacheKey $ck ) : CacheData
$ck CacheKey
Результат CacheData

setLifetime() публичный Метод

public setLifetime ( integer $lifetime ) : CacheData
$lifetime integer
Результат CacheData

stringify() публичный Метод

Converts this data to a string that can output. This is not a hash key or a serialization, but an actual render for humans.
public stringify ( CacheAbstract $c, $recurse = true )
$c CacheAbstract

unserialize() публичный статический Метод

Unserializes data and returns a new CacheData. This is what you should use to get the object data from the storage.
public static unserialize ( string $data ) : CacheData
$data string
Результат CacheData

updateDependenciesHash() публичный Метод

public updateDependenciesHash ( CacheAbstract $cache )
$cache CacheAbstract

updateDependenciesHashIfNull() публичный Метод

public updateDependenciesHashIfNull ( CacheAbstract $cache )
$cache CacheAbstract

Описание свойств

$data публичное свойство

The actual cached data
public array $data
Результат array

$dependencies публичное свойство

This is a storage of dependencies for this cache. This is stored here as the russian doll model will automatically push up dependencies. In the end this will probably be used by the storage for easy invalidation.
public array:CacheKey $dependencies
Результат array:CacheKey

$key публичное свойство

public CacheKey,cachearium $key
Результат CacheKey

$lifetime публичное свойство

Lifetime: how long this cache should live. It's up to the storage implementation the details of how this will be obeyed, if at all.
public int $lifetime
Результат integer