PHP 클래스 Jarves\Cache\Cacher

파일 보기 프로젝트 열기: jarves/jarves 1 사용 예제들

보호된 프로퍼티들

프로퍼티 타입 설명
$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