PHP 클래스 Gdn_Cache, vanilla

All cache objects should extend this to ensure a consistent public api for caching.
부터: 2.0.10
저자: Tim Gunter ([email protected])
파일 보기 프로젝트 열기: vanilla/vanilla 1 사용 예제들

공개 프로퍼티들

프로퍼티 타입 설명
$trace boolean
$trackGet array
$trackGets integer
$trackSet array
$trackSets integer
$trackTime integer

보호된 프로퍼티들

프로퍼티 타입 설명
$cacheType Type of cache this this: one of CACHE_TYPE_MEMORY, CACHE_TYPE_FILE, CACHE_TYPE_NULL.
$containers List of cache containers.
$features List of features this cache system supports.
$localCache Local in-memory cache of fetched data. This prevents duplicate gets to memcache.
$stores Memory copy of store containers.

공개 메소드들

메소드 설명
__construct ( )
activeCache ( ) : string Gets the short name of the currently active cache.
activeEnabled ( type $ForceEnable = false ) : boolean Get the status of the active cache.
activeStore ( type $ForceMethod = null ) : mixed Returns the storage data for the active cache.
add ( string $Key, mixed $Value, array $Options = [] ) : boolean Add a value to the cache.
addContainer ( array $Options ) : boolean Add a container to the cache pool.
config ( $Key = null, $Default = null ) * Get the value of a store-specific config
decrement ( string $Key, integer $Amount = 1, $Options = [] ) : integer Decrement the value of the provided key by {@link $Amount}.
exists ( string $Key ) : array Check if a value exists in the cache.
fail ( string $server ) Register a temporary server connection failure.
flush ( ) : boolean Invalidate all items in the cache.
get ( string $Key, array $Options = [] ) : mixed Retrieve a key's value from the cache.
getPrefix ( $ForcePrefix = null, $WithRevision = true )
getRevision ( $ForcePrefix = null, $Force = false )
hasFeature ( integer $Feature ) : mixed Check whether this cache supports the specified feature.
increment ( string $Key, integer $Amount = 1, $Options = [] ) : integer Increment the value of the provided key by {@link $Amount}.
incrementRevision ( )
initialize ( $ForceEnable = false, $ForceMethod = false ) : Gdn_Cache Determines the currently installed cache solution and returns a fresh instance of its object.
makeKey ( $Key, $Options )
online ( ) : boolean Is the current cache available?
option ( $Option = null, $Default = null ) * Get the value of a store-specific option.
registerFeature ( integer $Feature, mixed $Meta = true ) Flag this cache as being capable of performing a feature.
remove ( string $Key, array $Options = [] ) : boolean Remove a key/value pair from the cache.
replace ( string $Key, mixed $Value, array $Options = [] ) : boolean Replace an existing key's value with the provided value.
store ( string $Key, mixed $Value, array $Options = [] ) : boolean Store a value in the cache.
stripKey ( $Key, $Options )
trace ( $trace = null )
type ( ) : string Returns a constant describing the type of cache implementation this object represents.
unregisterFeature ( integer $Feature ) Remove feature flag from this cache, for the specific feature.

보호된 메소드들

메소드 설명
failure ( $Message )
fallback ( string $Key, array $Options ) : mixed
localClear ( ) Clear local cache (process memory cache).
localGet ( $key )
localSet ( $key, $value = null )

메소드 상세

__construct() 공개 메소드

public __construct ( )

activeCache() 공개 정적인 메소드

This method retrieves the name of the active cache according to the config file. It fires an event thereafter, allowing that value to be overridden by loaded plugins.
public static activeCache ( ) : string
리턴 string shortname of current auto active cache

activeEnabled() 공개 정적인 메소드

Return whether or not the current cache method is enabled.
public static activeEnabled ( type $ForceEnable = false ) : boolean
$ForceEnable type
리턴 boolean status of active cache

activeStore() 공개 정적인 메소드

For FileCache, the folder. For Memcache, the server(s).
public static activeStore ( type $ForceMethod = null ) : mixed
$ForceMethod type
리턴 mixed Active Store Location

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

This fails if the item already exists in the cache.
abstract public add ( string $Key, mixed $Value, array $Options = [] ) : boolean
$Key string Cache key used for storage
$Value mixed Value to be cached
$Options array
리턴 boolean true on success or false on failure.

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

Add a container to the cache pool.
abstract public addContainer ( array $Options ) : boolean
$Options array An array of options with container constants as keys. - CONTAINER_LOCATION: required. the location of the container. SERVER:IP, Filepath, etc. - CONTAINER_PERSISTENT: optional (default true). whether to use connect() or pconnect() where applicable. - CONTAINER_WEIGHT: optional (default 1). number of buckets to create for this server which in turn control its probability of it being selected. - CONTAINER_RETRYINT: optional (default 15s). controls how often a failed container will be retried, the default value is 15 seconds. - CONTAINER_TIMEOUT: optional (default 1s). amount of time to wait for connection to container before timing out. - CONTAINER_CALLBACK: optional (default null). callback to execute if container fails to open/connect.
리턴 boolean true on success or false on failure.

config() 공개 메소드

The option keys are generic and cross-cache, but are always stored under $Configuration['Cache'][ActiveCacheName]['Config'][*].
public config ( $Key = null, $Default = null )
$Key The config key to retrieve

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

This will fail if the key does not already exist. Cannot take the value of $Key below 0.
abstract public decrement ( string $Key, integer $Amount = 1, $Options = [] ) : integer
$Key string Cache key used for storage.
$Amount integer Amount to shift value down.
리턴 integer new value or false on failure.

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

Check if a value exists in the cache.
abstract public exists ( string $Key ) : array
$Key string Cache key used for storage.
리턴 array array(key => value) for existing key or false if not found.

fail() 공개 메소드

This method will attempt to temporarily excise the offending server from the connect roster for a period of time.
public fail ( string $server )
$server string

failure() 보호된 메소드

protected failure ( $Message )

fallback() 보호된 메소드

protected fallback ( string $Key, array $Options ) : mixed
$Key string Cache key.
$Options array
리턴 mixed

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

Gdn_Cache::Flush() invalidates all existing cache items immediately. After invalidation none of the items will be returned in response to a retrieval command (unless it's stored again under the same key after Gdn_Cache::Flush() has invalidated the items).
abstract public flush ( ) : boolean
리턴 boolean true on success of false on failure.

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

Retrieve a key's value from the cache.
abstract public get ( string $Key, array $Options = [] ) : mixed
$Key string Cache key used for storage.
$Options array
리턴 mixed key value or false on failure or not found.

getPrefix() 공개 메소드

public getPrefix ( $ForcePrefix = null, $WithRevision = true )

getRevision() 공개 메소드

public getRevision ( $ForcePrefix = null, $Force = false )

hasFeature() 공개 메소드

Check whether this cache supports the specified feature.
public hasFeature ( integer $Feature ) : mixed
$Feature integer One of the feature constants.
리턴 mixed $Meta returns the meta data supplied during RegisterFeature().

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

This will fail if the key does not already exist. Cannot take the value of $Key below 0.
abstract public increment ( string $Key, integer $Amount = 1, $Options = [] ) : integer
$Key string Cache key used for storage.
$Amount integer Amount to shift value up.
리턴 integer new value or false on failure.

incrementRevision() 공개 메소드

public incrementRevision ( )

initialize() 공개 정적인 메소드

Determines the currently installed cache solution and returns a fresh instance of its object.
public static initialize ( $ForceEnable = false, $ForceMethod = false ) : Gdn_Cache
리턴 Gdn_Cache

localClear() 보호된 정적인 메소드

Clear local cache (process memory cache).
protected static localClear ( )

localGet() 보호된 메소드

protected localGet ( $key )

localSet() 보호된 메소드

protected localSet ( $key, $value = null )

makeKey() 공개 메소드

public makeKey ( $Key, $Options )

online() 공개 메소드

Is the current cache available?
public online ( ) : boolean
리턴 boolean

option() 공개 메소드

The option keys are specific to the active cache type, but are always stored under $Configuration['Cache'][ActiveCacheName]['Option'][*].
public option ( $Option = null, $Default = null )
$Option The option key to retrieve

registerFeature() 공개 메소드

FEATURE_COMPRESS: this cache can compress and decompress values on the fly FEATURE_TIMEOUT: this cache can timeout while reading / writing FEATURE_EXPIRY: this cache can expire keys
public registerFeature ( integer $Feature, mixed $Meta = true )
$Feature integer One of the feature constants.
$Meta mixed An optional data to return when calling HasFeature. default true.

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

Remove a key/value pair from the cache.
abstract public remove ( string $Key, array $Options = [] ) : boolean
$Key string Cache key used for storage.
$Options array
리턴 boolean true on success or false on failure.

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

This will fail if the provided key does not already exist.
abstract public replace ( string $Key, mixed $Value, array $Options = [] ) : boolean
$Key string Cache key used for storage.
$Value mixed Value to be cached.
$Options array
리턴 boolean true on success or false on failure.

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

This works regardless of whether the item already exists in the cache.
abstract public store ( string $Key, mixed $Value, array $Options = [] ) : boolean
$Key string Cache key used for storage.
$Value mixed Value to be cached.
$Options array An array of cache feature constants. - FEATURE_COMPRESS: Allows items to be internally compressed/decompressed (bool). - FEATURE_EXPIRY: Allows items to autoexpire (seconds). - FEATURE_NOPREFIX: Allows disabling usage of key prefix (bool). - FEATURE_FORCEPREFIX: Allows forcing alternate key prefix (string). - FEATURE_FALLBACK: Allows querying DB for missing keys, or firing a callback (see Gdn_Cache->Fallback).
리턴 boolean true on success or false on failure.

stripKey() 공개 메소드

public stripKey ( $Key, $Options )

trace() 공개 정적인 메소드

public static trace ( $trace = null )

type() 공개 메소드

Returns a constant describing the type of cache implementation this object represents.
public type ( ) : string
리턴 string Type of cache. One of CACHE_TYPE_MEMORY, CACHE_TYPE_FILE, CACHE_TYPE_NULL

unregisterFeature() 공개 메소드

Remove feature flag from this cache, for the specific feature.
public unregisterFeature ( integer $Feature )
$Feature integer One of the feature constants.

프로퍼티 상세

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

Type of cache this this: one of CACHE_TYPE_MEMORY, CACHE_TYPE_FILE, CACHE_TYPE_NULL.
protected $cacheType

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

List of cache containers.
protected $containers

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

List of features this cache system supports.
protected $features

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

Local in-memory cache of fetched data. This prevents duplicate gets to memcache.
protected static $localCache

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

Memory copy of store containers.
protected static $stores

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

public static bool $trace
리턴 boolean

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

public static array $trackGet
리턴 array

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

public static int $trackGets
리턴 integer

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

public static array $trackSet
리턴 array

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

public static int $trackSets
리턴 integer

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

public static int $trackTime
리턴 integer