PHP Class 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.
Afficher le fichier
Open project: unionofrad/lithium
Class Usage Examples
Méthodes publiques
Méthode |
Description |
|
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. |
|
Méthodes protégées
Method Details
_addScopePrefix()
protected méthode
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. |
Résultat |
array |
Prefixed keys array. |
_removeScopePrefix()
protected méthode
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 |
Résultat |
boolean |
`true` on successful clearing, `false` if failed partially or entirely. |
decrement()
abstract public méthode
Performs a decrement operation on specified numeric cache item.
delete()
abstract public méthode
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. |
Résultat |
boolean |
`true` on successful delete, `false` otherwise. |
enabled()
public static méthode
Override to check for preconditions.
increment()
abstract public méthode
Performs an increment operation on specified numeric cache item.
read()
abstract public méthode
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. |
Résultat |
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()
abstract public méthode
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`. |
Résultat |
boolean |
`true` on successful write, `false` otherwise. |