PHP Класс Jarves\Cache\Cacher

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

Защищенные свойства (Protected)

Свойство Тип Описание
$distributedCache Jarves\Cache\Backend\AbstractCache
$fastCache Jarves\Cache\Backend\AbstractCache
$stopwatch Jarves\StopwatchHelper

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

Метод Описание
__construct ( StopwatchHelper $stopwatch, AbstractCache $distributedCache, AbstractCache $fastCache )
deleteDistributedCache ( string $key ) Deletes a distributed cache
getDistributedCache ( string $key ) : mixed Returns a distributed cache value.
getFastCache ( string $key ) : mixed Returns a local cache value.
invalidateCache ( string $key, integer $time = null ) : boolean Marks a code as invalidate beginning at $time.
isCacheIsValid ( $key, $timestamp ) : integer | null Returns latest invalidation timestamp for the given $key.
setDistributedCache ( string $key, mixed $value, integer $lifeTime = null ) : boolean Sets a distributed cache.
setFastCache ( string $key, mixed $value, integer $lifeTime = null ) : boolean Sets a local cache using very fast cache techniques like apc_store or php arrays.

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

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

public __construct ( StopwatchHelper $stopwatch, AbstractCache $distributedCache, AbstractCache $fastCache )
$stopwatch Jarves\StopwatchHelper
$distributedCache Jarves\Cache\Backend\AbstractCache
$fastCache Jarves\Cache\Backend\AbstractCache

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

Deletes a distributed cache
public deleteDistributedCache ( string $key )
$key string

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

This uses cache invalidation mechanism described in
См. также: setDistributedCache() for more information invalidateCache().
public getDistributedCache ( string $key ) : mixed
$key string
Результат mixed null when not found

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

Returns a local cache value.
public getFastCache ( string $key ) : mixed
$key string
Результат mixed null when not found

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

This is the distributed cache controller. Use it if you want to invalidate caches on a distributed backend (setDistributedCache() and getDistributedCache()). You don't have to define the full key, instead you can pass only the starting part of the key. This means, if you have following caches defined: - news/list/2 - news/list/3 - news/list/4 - news/comments/134 - news/comments/51 you can mark all listing caches as invalid by calling - invalidateCache('news/list'); or mark all caches as invalid which starts with news/ you can call: - invalidateCache('news'); The invalidation mechanism explodes the key by / and checks all levels whether they're marked as invalid (through a microsecond timestamp) or not. Default is $time is mark all caches as invalid which are older than CURRENT. This method is called by the Jarves\Configuration\Event::$clearCaches configuration
public invalidateCache ( string $key, integer $time = null ) : boolean
$key string
$time integer Unix timestamp. Default is microtime(true). Uses float for ms.
Результат boolean

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

Returns an timestamp as integer which tells the cache handler that all stored caches before this timestamp are automatically invalide. Returns null when no invalidation has set yet, means also that the cache with given key is valid.
public isCacheIsValid ( $key, $timestamp ) : integer | null
Результат integer | null

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

This stores a ms timestamp on the distributed cache (Jarves::setCache()) and the actual data on the high-speed cache driver (Jarves::setFastCache()). This mechanism makes sure, you gain the maximum performance by using the fast cache driver to store the actual data and using the distributed cache driver to store a ms timestamp where we can check (over several jarves.cms installations) whether the cache is still valid or not. Use Jarves::invalidateCache($key) to invalidate this cache. You don't have to define the full key, instead you can pass only a part of the key.
См. также: invalidateCache for more information. Don't mix the usage of getDistributedCache() and getCache() since this method stores extra values at the value, which makes getCache() returning something invalid.
public setDistributedCache ( string $key, mixed $value, integer $lifeTime = null ) : boolean
$key string
$value mixed Only simple data types. Serialize your value if you have objects/arrays.
$lifeTime integer
Результат boolean

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

Does not use cache invalidation mechanism. Notes: Not practical for load balances or php-pm scenarios. Not even practical when you use PHP in PHP-FPM, because there are several php instances as well which do nothing know about cache refreshing in this fast cache. Is only useful for configuration purposes at bootstrap or in combination with the invalidation mechanism (which is then the same as if you would call setDistributedCache())
public setFastCache ( string $key, mixed $value, integer $lifeTime = null ) : boolean
$key string
$value mixed Only simple data types. Serialize your value if you have objects/arrays.
$lifeTime integer
Результат boolean

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

$distributedCache защищенное свойство

protected AbstractCache,Jarves\Cache\Backend $distributedCache
Результат Jarves\Cache\Backend\AbstractCache

$fastCache защищенное свойство

protected AbstractCache,Jarves\Cache\Backend $fastCache
Результат Jarves\Cache\Backend\AbstractCache

$stopwatch защищенное свойство

protected StopwatchHelper,Jarves $stopwatch
Результат Jarves\StopwatchHelper