PHP 클래스 lithium\storage\cache\adapter\XCache
The XCache adapter is meant to be used through the
Cache interface,
which abstracts away key generation, adapter instantiation and filter
implementation.
A simple configuration of this adapter can be accomplished in
app/config/bootstrap/cache.php
as follows:
{{{
use lithium\storage\Cache;
Cache::config(array(
'cache-config-name' => array(
'adapter' => 'XCache',
'username' => 'user',
'password' => 'pass'
)
));
}}}
Note that the
username and
password configuration fields are only required if
you wish to use
XCache::clear() - all other methods do not require XCache administrator
credentials.
This XCache adapter provides basic support for
write,
read,
delete
and
clear cache functionality, as well as allowing the first four
methods to be filtered as per the Lithium filtering system.
This adapter does *not* allow multi-key operations for any methods.
파일 보기
프로젝트 열기: unionofrad/lithium
1 사용 예제들
공개 메소드들
메소드 |
설명 |
|
__construct ( array $config = [] ) : void |
Constructor. |
|
clear ( ) : boolean |
Clears entire user-space 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 an atomic 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 the XCache extension has been installed and
if the userspace cache is available. |
|
increment ( string $key, integer $offset = 1 ) : integer | boolean |
Performs an atomic 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. |
|
메소드 상세
public __construct ( array $config = [] ) : void |
$config |
array |
Configuration for this cache adapter. These settings are queryable
through `Cache::config('name')`. The available options are as follows:
- `'scope'` _string_: Scope which will prefix keys; per default not set.
- `'expiry'` _mixed_: The default expiration time for cache values, if no value
is otherwise set. Can be either a `strtotime()` compatible tring or TTL in
seconds. To indicate items should not expire use `Cache::PERSIST`. Defaults
to `+1 hour`. |
리턴 |
void |
|
This method requires valid XCache admin credentials to be set when the adapter
was configured, due to the use of the xcache_clear_cache admin method. If the
xcache.admin.enable_auth ini setting is set to Off, no credentials required.
The behavior and result when removing a single key
during this process fails is unknown.
Note that, as per the XCache specification:
If the item's value is not numeric, it is treated as if the value were 0.
It is possible to decrement a value into the negative integers.
Note that this is not an atomic operation when using multiple keys.
public delete ( array $keys ) : boolean |
$keys |
array |
Keys to uniquely identify the cached items. |
리턴 |
boolean |
`true` on successful delete, `false` otherwise. |
Determines if the XCache extension has been installed and
if the userspace cache is available.
Note that, as per the XCache specification:
If the item's value is not numeric, it is treated as if the value were 0.
Note that this is not an atomic operation when using multiple keys.
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. |
Note that this is not an atomic operation when using multiple keys.
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. |