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])
Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
$trace boolean
$trackGet array
$trackGets integer
$trackSet array
$trackSets integer
$trackTime integer

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

Свойство Тип Описание
$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