PHP Класс lithium\storage\cache\Adapter

Each adapter provides a consistent interface for the basic cache operations of write, read, delete, increment and decrement which can always be _used interchangeably_ between and must be implemented by all adapters. Functionality for clear, clean may or may not be implemented by an adapter. Calling a method that is not implemented will simply return false. An adapter may provide access to additional methods. It's always possible to call them directly. This allows a very wide range of flexibility, at the cost of portability. Cache::adapter('default')->methodName($argument); It is not guaranteed that all operations are atomic, but adapters will try to perform atomic operations wherever possible. If you rely on atomicity of operations you must choose an appropriate adapter that explitcly supports these. Adapters may handle serialization and/or multi-keys natively others only synthetically.
Наследование: extends lithium\core\Object
Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
clean ( ) : boolean Perform garbage collection.
clear ( ) : boolean Clears entire cache by flushing it. All cache keys using the configuration but *without* honoring the scope are removed.
decrement ( string $key, integer $offset = 1 ) : integer | boolean Performs a decrement operation on specified numeric cache item.
delete ( array $keys ) : boolean Will attempt to remove specified keys from the user space cache.
enabled ( ) : boolean Determines if an adapter is available for usage and all preconditions are met (i.e. extension installed).
increment ( string $key, integer $offset = 1 ) : integer | boolean Performs an increment operation on specified numeric cache item.
read ( array $keys ) : array Read values from the cache. Will attempt to return an array of data containing key/value pairs of the requested data.
write ( array $keys, string | integer $expiry = null ) : boolean Write values to the cache. All items to be cached will receive an expiration time of $expiry.

Защищенные методы

Метод Описание
_addScopePrefix ( string $scope, array $keys, string $separator = ':' ) : array Adds scope prefix to keys using separator.
_removeScopePrefix ( string $scope, array $data, string $separator = ':' ) : array Removes scope prefix from keys.

Описание методов

_addScopePrefix() защищенный Метод

Adds scope prefix to keys using separator.
protected _addScopePrefix ( string $scope, array $keys, string $separator = ':' ) : array
$scope string Scope to use when prefixing.
$keys array Array of keys either with or without mapping to values.
$separator string String to use when separating scope from key.
Результат array Prefixed keys array.

_removeScopePrefix() защищенный Метод

Removes scope prefix from keys.
protected _removeScopePrefix ( string $scope, array $data, string $separator = ':' ) : array
$scope string Scope initially used when prefixing.
$data array
$separator string Separator used when prefix keys initially.
Результат array Keys array with prefix removed from each key.

clean() публичный Метод

Perform garbage collection.
public clean ( ) : boolean
Результат boolean `true` on successful clean, `false` otherwise.

clear() публичный Метод

Clears entire cache by flushing it. All cache keys using the configuration but *without* honoring the scope are removed.
public clear ( ) : boolean
Результат boolean `true` on successful clearing, `false` if failed partially or entirely.

decrement() абстрактный публичный Метод

Performs a decrement operation on specified numeric cache item.
abstract public decrement ( string $key, integer $offset = 1 ) : integer | boolean
$key string Key of numeric cache item to decrement.
$offset integer Offset to decrement - defaults to `1`.
Результат integer | boolean The item's new value on successful decrement, else `false`.

delete() абстрактный публичный Метод

Will attempt to remove specified keys from the user space cache.
abstract public delete ( array $keys ) : boolean
$keys array Keys to uniquely identify the cached items.
Результат boolean `true` on successful delete, `false` otherwise.

enabled() публичный статический Метод

Override to check for preconditions.
public static enabled ( ) : boolean
Результат boolean `true` if enabled, `false` otherwise.

increment() абстрактный публичный Метод

Performs an increment operation on specified numeric cache item.
abstract public increment ( string $key, integer $offset = 1 ) : integer | boolean
$key string Key of numeric cache item to increment.
$offset integer Offset to increment - defaults to `1`.
Результат integer | boolean The item's new value on successful increment, else `false`.

read() абстрактный публичный Метод

Read values from the cache. Will attempt to return an array of data containing key/value pairs of the requested data.
abstract public read ( array $keys ) : array
$keys array Keys to uniquely identify the cached items.
Результат array Cached values keyed by cache keys on successful read, keys which could not be read will not be included in the results array.

write() абстрактный публичный Метод

Write values to the cache. All items to be cached will receive an expiration time of $expiry.
abstract public write ( array $keys, string | integer $expiry = null ) : boolean
$keys array Key/value pairs with keys to uniquely identify the to-be-cached item.
$expiry string | integer A `strtotime()` compatible cache time or TTL in seconds. To persist an item use `\lithium\storage\Cache::PERSIST`.
Результат boolean `true` on successful write, `false` otherwise.