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.
Показать файл
Открыть проект
Примеры использования класса
Открытые методы
Метод |
Описание |
|
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()
защищенный Метод
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.
Perform garbage collection.
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.
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.
increment()
абстрактный публичный Метод
Performs an increment operation on specified numeric cache item.
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. |