PHP 클래스 Prado\Caching\TCache

TCache is the base class for cache classes with different cache storage implementation. TCache implements the interface {@link ICache} with the following methods, - {@link get} : retrieve the value with a key (if any) from cache - {@link set} : store the value with a key into cache - {@link add} : store the value only if cache does not have this key - {@link delete} : delete the value with the specified key from cache - {@link flush} : delete all values from cache Each value is associated with an expiration time. The {@link get} operation ensures that any expired value will not be returned. The expiration time by the number of seconds. A expiration time 0 represents never expire. By definition, cache does not ensure the existence of a value even if it never expires. Cache is not meant to be an persistent storage. Child classes must implement the following methods: - {@link getValue} - {@link setValue} - {@link addValue} - {@link deleteValue} and optionally {@link flush} Since version 3.1.2, TCache implements the \ArrayAccess interface such that the cache acts as an array.
부터: 3.0
저자: Qiang Xue ([email protected])
상속: extends Prado\TModule, implements Prado\Caching\ICache, implements ArrayAccess
파일 보기 프로젝트 열기: pradosoft/prado 1 사용 예제들

공개 메소드들

메소드 설명
add ( $id, $value, $expire, $dependency = null ) : boolean Stores a value identified by a key into cache if the cache does not contain this key.
delete ( $id ) : boolean Deletes a value with the specified key from cache
flush ( ) Deletes all values from cache.
get ( $id ) : mixed Retrieves a value from cache with a specified key.
getKeyPrefix ( ) : string
getPrimaryCache ( ) : boolean
init ( $config ) Initializes the cache module.
offsetExists ( $id ) : boolean Returns whether there is a cache entry with a specified key.
offsetGet ( $id ) : mixed Retrieves the value from cache with a specified key.
offsetSet ( $id, $value ) Stores the value identified by a key into cache.
offsetUnset ( $id ) : boolean Deletes the value with the specified key from cache This method is required by the interface \ArrayAccess.
set ( $id, $value, $expire, $dependency = null ) : boolean Stores a value identified by a key into cache.
setKeyPrefix ( $value )
setPrimaryCache ( $value )

보호된 메소드들

메소드 설명
addValue ( $key, $value, $expire ) : boolean Stores a value identified by a key into cache if the cache does not contain this key.
deleteValue ( $key ) : boolean Deletes a value with the specified key from cache This method should be implemented by child classes to delete the data from actual cache storage.
generateUniqueKey ( $key ) : sring
getValue ( $key ) : string Retrieves a value from cache with a specified key.
setValue ( $key, $value, $expire ) : boolean Stores a value identified by a key in cache.

메소드 상세

add() 공개 메소드

Nothing will be done if the cache already contains the key or if value is empty.
public add ( $id, $value, $expire, $dependency = null ) : boolean
리턴 boolean true if the value is successfully stored into cache, false otherwise

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

This method should be implemented by child classes to store the data in specific cache storage. The uniqueness and dependency are handled in {@link add()} already. So only the implementation of data storage is needed.
abstract protected addValue ( $key, $value, $expire ) : boolean
리턴 boolean true if the value is successfully stored into cache, false otherwise

delete() 공개 메소드

Deletes a value with the specified key from cache
public delete ( $id ) : boolean
리턴 boolean if no error happens during deletion

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

Deletes a value with the specified key from cache This method should be implemented by child classes to delete the data from actual cache storage.
abstract protected deleteValue ( $key ) : boolean
리턴 boolean if no error happens during deletion

flush() 공개 메소드

Be careful of performing this operation if the cache is shared by multiple applications. Child classes may implement this method to realize the flush operation.
public flush ( )

generateUniqueKey() 보호된 메소드

protected generateUniqueKey ( $key ) : sring
리턴 sring a key generated from the provided key which ensures the uniqueness across applications

get() 공개 메소드

Retrieves a value from cache with a specified key.
public get ( $id ) : mixed
리턴 mixed the value stored in cache, false if the value is not in the cache or expired.

getKeyPrefix() 공개 메소드

public getKeyPrefix ( ) : string
리턴 string a unique prefix for the keys of cached values. If it is not explicitly set, it will take the value of {@link TApplication::getUniqueID}.

getPrimaryCache() 공개 메소드

public getPrimaryCache ( ) : boolean
리턴 boolean whether this cache module is used as primary/system cache. A primary cache is used by PRADO core framework to cache data such as parsed templates, themes, etc.

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

This method should be implemented by child classes to store the data in specific cache storage. The uniqueness and dependency are handled in {@link get()} already. So only the implementation of data retrieval is needed.
abstract protected getValue ( $key ) : string
리턴 string the value stored in cache, false if the value is not in the cache or expired.

init() 공개 메소드

This method initializes the cache key prefix and registers the cache module with the application if the cache is primary.
public init ( $config )

offsetExists() 공개 메소드

This method is required by the interface \ArrayAccess.
public offsetExists ( $id ) : boolean
리턴 boolean

offsetGet() 공개 메소드

This method is required by the interface \ArrayAccess.
public offsetGet ( $id ) : mixed
리턴 mixed the value stored in cache, false if the value is not in the cache or expired.

offsetSet() 공개 메소드

If the cache already contains such a key, the existing value will be replaced with the new ones. To add expiration and dependencies, use the set() method. This method is required by the interface \ArrayAccess.
public offsetSet ( $id, $value )

offsetUnset() 공개 메소드

Deletes the value with the specified key from cache This method is required by the interface \ArrayAccess.
public offsetUnset ( $id ) : boolean
리턴 boolean if no error happens during deletion

set() 공개 메소드

If the cache already contains such a key, the existing value and expiration time will be replaced with the new ones. If the value is empty, the cache key will be deleted.
public set ( $id, $value, $expire, $dependency = null ) : boolean
리턴 boolean true if the value is successfully stored into cache, false otherwise

setKeyPrefix() 공개 메소드

public setKeyPrefix ( $value )

setPrimaryCache() 공개 메소드

또한 보기: getPrimaryCache
public setPrimaryCache ( $value )

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

This method should be implemented by child classes to store the data in specific cache storage. The uniqueness and dependency are handled in {@link set()} already. So only the implementation of data storage is needed.
abstract protected setValue ( $key, $value, $expire ) : boolean
리턴 boolean true if the value is successfully stored into cache, false otherwise