PHP 클래스 Cachearium\CacheAbstract

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

공개 프로퍼티들

프로퍼티 타입 설명
$debugLogFile Controls debug to a file
$debugOnPage boolean Controls debug on html page for all Cache backends.

보호된 프로퍼티들

프로퍼티 타입 설명
$cache_log array Stores cache log for debugging.
$enabled boolean Is this cache enabled?
$lifetime
$namespace string Initialize it to a unique string. If you are not running multiple instances, ignore.
$should_log boolean Is log enabled? Log can take a lot of RAM, so only turn this on when profiling.
$summary array Array for basic cache profiling. Keys are CacheLogEnum, values are counters.

공개 메소드들

메소드 설명
appendCallback ( callable $callback ) : boolean Appends a callback to the current start()/end() cache
clean ( CacheKey $k ) : boolean Cleans cache: all entries with a certain $base and $id in the $key are deleted.
cleanP ( $base, $id ) : boolean Cleans cache: all entries with a certain $base and $id
clear ( ) Clears entire cache. Use sparingly.
clearAll ( ) Clears all cache classes.
cssDebug ( ) Renders CSS for live view debugging of cached data.
delete ( CacheKey $k ) : boolean Deletes an entry from the cache
deleteP ( string $base, string $id, mixed $sub = null )
disable ( ) : CacheAbstract Disable this cache
dumpSummary ( ) Dumps a short HTML summary of the cache hits/misses
enable ( ) : CacheAbstract Enable this cache
end ( $print = true ) Ends the cache start().
factory ( string $backend ) : CacheAbstract Returns a cache
footerDebug ( ) Extensive footer debug code. Shows which parts of the HTML were cached or missed visually. Great!
get ( CacheKey $k ) : mixed Get cached entry.
getData ( CacheKey $k ) : CacheData Same as get, but assumes data was stored with a CacheData object and will treat it accordingly.
getDataP ( string $base, string $id, mixed $sub = null ) Same as getData(), but expanded parameters.
getDefaultLifetime ( )
getLogSummary ( ) : array() Returns basic cache statistics. See $summary.
getMulti ( array $cacheid, callable $callback = null ) : array:mixed Gets data from multiple cache keys at once
getNamespace ( ) : string
getP ( string $base, string $id, mixed $sub = null ) : mixed Same as get(), but expanded parameters.
increment ( integer $value, CacheKey $k, integer $default ) : integer Increment a variable. Backend deals with this, but in general this is atomic.
invalidate ( CacheKey $k ) Invalidates a dependency index. If the index does not exist it is created.
isEnabled ( ) : True
logHigh ( $message ) High level log for testing and debugging
newEnd ( $print = true )
newstart ( CacheKey $k, $lifetime = null, $fail = false )
prefetch ( array $data ) Prefetches data which will be used. This avoids multiple trips to the cache server if they can be avoided.
recursiveEnd ( boolean $print = true ) : string
recursiveStart ( CacheKey $k, integer $lifetime = null, boolean $print = true, boolean $fail = false ) : string
recursiveStartP ( $base, $id, $sub = null, $lifetime = null, $print = true, $fail = false )
report ( ) Generates a report for this backend
resetLogSummary ( )
setDefaultLifetime ( number $lifetime )
setEnabled ( $b ) : CacheAbstract Enable this cache
setLog ( boolean $b ) : CacheAbstract
setNamespace ( string $name )
start ( CacheKey $k, string $lifetime = null, boolean $print = true, boolean $fail = false ) : boolean | string Starts a cache if it doesn't exist, or outputs the data and returns true.
startCallback ( CacheKey $k, callable $c, array $cparams = [], integer $lifetime = null ) start() using a callable. Same as start()/c()/end().
startP ( $base, $id, $sub = null, $lifetime = null, $print = true, $fail = false )
store ( mixed $data, CacheKey $k, integer $lifetime ) : boolean Saves data in cache.
storeData ( CacheData $data, number $lifetime ) : boolean Same as store() but expanded parameters
storeP ( mixed $data, string $base, string $id, string $sub = null, number $lifetime ) : boolean Same as store() but expanded parameters

보호된 메소드들

메소드 설명
hashKey ( CacheKey $k ) Returns a key given parameters. This is up to storage and different values may be returned for the same parameters, as storages are likely to use key-based cache expiration.
keyFromDeps ( CacheKey $k, $deps )
log ( string $status, CacheKey $k, integer $lifetime ) Logs cache accesses for debugging
printProbeEnd ( string $key, CacheData $cachedata ) Prints HTML for cache debug probes -> closes tag
printProbeStart ( string $key, CacheData $cachedata, string $type ) Prints HTML for cache debug probes -> opens tag

비공개 메소드들

메소드 설명
extraSub ( unknown &$sub ) Get extra sub

메소드 상세

appendCallback() 공개 메소드

Callbacks are always called at runtime, their result is never cached at this level. You may cache it in the callback, of course.
public appendCallback ( callable $callback ) : boolean
$callback callable
리턴 boolean

clean() 공개 메소드

Cleans cache: all entries with a certain $base and $id in the $key are deleted.
public clean ( CacheKey $k ) : boolean
$k CacheKey
리턴 boolean true if no problem

cleanP() 추상적인 공개 메소드

Cleans cache: all entries with a certain $base and $id
abstract public cleanP ( $base, $id ) : boolean
리턴 boolean true if no problem

clear() 추상적인 공개 메소드

Clears entire cache. Use sparingly.
abstract public clear ( )

clearAll() 공개 정적인 메소드

Clears all cache classes.
public static clearAll ( )

cssDebug() 공개 정적인 메소드

Renders CSS for live view debugging of cached data.
public static cssDebug ( )

delete() 추상적인 공개 메소드

Deletes an entry from the cache
abstract public delete ( CacheKey $k ) : boolean
$k CacheKey
리턴 boolean

deleteP() 공개 메소드

또한 보기: delete()
public deleteP ( string $base, string $id, mixed $sub = null )
$base string
$id string
$sub mixed

disable() 공개 메소드

Disable this cache
public disable ( ) : CacheAbstract
리턴 CacheAbstract

dumpSummary() 공개 정적인 메소드

Dumps a short HTML summary of the cache hits/misses
public static dumpSummary ( )

enable() 공개 메소드

Enable this cache
public enable ( ) : CacheAbstract
리턴 CacheAbstract this

end() 공개 메소드

Ends the cache start().
또한 보기: recursiveEnd()
public end ( $print = true )

factory() 공개 정적인 메소드

Returns a cache
public static factory ( string $backend ) : CacheAbstract
$backend string
리턴 CacheAbstract

footerDebug() 공개 정적인 메소드

Extensive footer debug code. Shows which parts of the HTML were cached or missed visually. Great!
public static footerDebug ( )

get() 추상적인 공개 메소드

Get cached entry.
abstract public get ( CacheKey $k ) : mixed
$k CacheKey
리턴 mixed

getData() 공개 메소드

Same as get, but assumes data was stored with a CacheData object and will treat it accordingly.
public getData ( CacheKey $k ) : CacheData
$k CacheKey
리턴 CacheData

getDataP() 공개 메소드

Same as getData(), but expanded parameters.
또한 보기: getData()
public getDataP ( string $base, string $id, mixed $sub = null )
$base string
$id string
$sub mixed

getDefaultLifetime() 공개 메소드

public getDefaultLifetime ( )

getLogSummary() 공개 정적인 메소드

Returns basic cache statistics. See $summary.
public static getLogSummary ( ) : array()
리턴 array()

getMulti() 공개 메소드

Backends may override this to provide an efficient implementation over multiple calls to get().
public getMulti ( array $cacheid, callable $callback = null ) : array:mixed
$cacheid array List of cache keys
$callback callable if present will be called for any \NotCachedExceptions. Callback should have this signature: (CacheAbstract $c, CacheKey $k)
리턴 array:mixed

getNamespace() 공개 메소드

public getNamespace ( ) : string
리턴 string

getP() 공개 메소드

Same as get(), but expanded parameters.
또한 보기: getK
public getP ( string $base, string $id, mixed $sub = null ) : mixed
$base string
$id string
$sub mixed
리턴 mixed

hashKey() 추상적인 보호된 메소드

Returns a key given parameters. This is up to storage and different values may be returned for the same parameters, as storages are likely to use key-based cache expiration.
abstract protected hashKey ( CacheKey $k )
$k CacheKey

increment() 추상적인 공개 메소드

Backend must only guarantee that the increment is made, but the final value may not be current + $value due to concurrent accesses.
abstract public increment ( integer $value, CacheKey $k, integer $default ) : integer
$value integer
$k CacheKey
$default integer If key is not in cache, this value is returned.
리턴 integer

invalidate() 공개 메소드

Invalidates a dependency index. If the index does not exist it is created.
public invalidate ( CacheKey $k )
$k CacheKey

isEnabled() 공개 메소드

public isEnabled ( ) : True
리턴 True if cache is enabled, working and storing/retrieving data.

keyFromDeps() 보호된 메소드

protected keyFromDeps ( CacheKey $k, $deps )
$k CacheKey

log() 보호된 메소드

Logs cache accesses for debugging
protected log ( string $status, CacheKey $k, integer $lifetime )
$status string CacheLogEnum constant
$k CacheKey The message to print.
$lifetime integer

logHigh() 공개 정적인 메소드

High level log for testing and debugging
public static logHigh ( $message )

newEnd() 공개 메소드

public newEnd ( $print = true )

newstart() 공개 메소드

public newstart ( CacheKey $k, $lifetime = null, $fail = false )
$k CacheKey

prefetch() 추상적인 공개 메소드

Backend may ignore this call and implement a noop.
abstract public prefetch ( array $data )
$data array array(0 => CacheKey, ...)

printProbeEnd() 보호된 메소드

Prints HTML for cache debug probes -> closes tag
protected printProbeEnd ( string $key, CacheData $cachedata )
$key string
$cachedata CacheData

printProbeStart() 보호된 메소드

Prints HTML for cache debug probes -> opens tag
protected printProbeStart ( string $key, CacheData $cachedata, string $type )
$key string
$cachedata CacheData
$type string

recursiveEnd() 공개 메소드

public recursiveEnd ( boolean $print = true ) : string
$print boolean
리턴 string The string. If $print == true the string is printed as well.

recursiveStart() 공개 메소드

public recursiveStart ( CacheKey $k, integer $lifetime = null, boolean $print = true, boolean $fail = false ) : string
$k CacheKey
$lifetime integer if null uses the class default
$print boolean
$fail boolean if true throws a NotCachedException if not cached.
리턴 string The cached item as a string or false if not cached.

recursiveStartP() 공개 메소드

또한 보기: recursiveStart()
public recursiveStartP ( $base, $id, $sub = null, $lifetime = null, $print = true, $fail = false )

report() 추상적인 공개 메소드

Generates a report for this backend
abstract public report ( )

resetLogSummary() 공개 정적인 메소드

public static resetLogSummary ( )

setDefaultLifetime() 공개 메소드

public setDefaultLifetime ( number $lifetime )
$lifetime number 0 for infinite

setEnabled() 최종 공개 메소드

Enable this cache
final public setEnabled ( $b ) : CacheAbstract
리턴 CacheAbstract this

setLog() 공개 메소드

public setLog ( boolean $b ) : CacheAbstract
$b boolean
리턴 CacheAbstract

setNamespace() 공개 메소드

public setNamespace ( string $name )
$name string An optional namespace.

start() 공개 메소드

Calls extraSub().
public start ( CacheKey $k, string $lifetime = null, boolean $print = true, boolean $fail = false ) : boolean | string
$k CacheKey
$lifetime string The lifetime, in seconds
$print boolean if True echoes the data
$fail boolean if false throws an exception if something happens, such as not cached
리턴 boolean | string True if cached

startCallback() 공개 메소드

start() using a callable. Same as start()/c()/end().
public startCallback ( CacheKey $k, callable $c, array $cparams = [], integer $lifetime = null )
$k CacheKey
$c callable A callable. Whatever it prints will be cached.
$cparams array parameters for the callback, optional
$lifetime integer

startP() 공개 메소드

또한 보기: start()
public startP ( $base, $id, $sub = null, $lifetime = null, $print = true, $fail = false )

store() 추상적인 공개 메소드

Saves data in cache.
abstract public store ( mixed $data, CacheKey $k, integer $lifetime ) : boolean
$data mixed Data to save in cache
$k CacheKey
$lifetime integer The lifetime in sceonds, although it is up to the implementation whether it is respected or not.
리턴 boolean true if no problem

storeData() 공개 메소드

Same as store() but expanded parameters
또한 보기: store()
public storeData ( CacheData $data, number $lifetime ) : boolean
$data CacheData
$lifetime number
리턴 boolean true if no problem

storeP() 공개 메소드

Same as store() but expanded parameters
또한 보기: store()
public storeP ( mixed $data, string $base, string $id, string $sub = null, number $lifetime ) : boolean
$data mixed
$base string
$id string
$sub string
$lifetime number
리턴 boolean true if no problem

프로퍼티 상세

$cache_log 보호되어 있는 프로퍼티

Stores cache log for debugging.
protected array $cache_log
리턴 array

$debugLogFile 공개적으로 정적으로 프로퍼티

Controls debug to a file
public static $debugLogFile

$debugOnPage 공개적으로 정적으로 프로퍼티

Controls debug on html page for all Cache backends.
public static bool $debugOnPage
리턴 boolean

$enabled 보호되어 있는 프로퍼티

Is this cache enabled?
protected bool $enabled
리턴 boolean

$lifetime 보호되어 있는 프로퍼티

protected $lifetime

$namespace 보호되어 있는 프로퍼티

Initialize it to a unique string. If you are not running multiple instances, ignore.
protected string $namespace
리턴 string

$should_log 보호되어 있는 프로퍼티

Is log enabled? Log can take a lot of RAM, so only turn this on when profiling.
protected bool $should_log
리턴 boolean

$summary 보호되어 있는 정적으로 프로퍼티

Array for basic cache profiling. Keys are CacheLogEnum, values are counters.
protected static array $summary
리턴 array