Class CMemCache
CMemCache implements a cache application component based on memcached.
CMemCache can be configured with a list of memcache servers by settings its setServers servers property. By default, CMemCache assumes there is a memcache server running on localhost at port 11211.
See CCache
manual for common cache operations that are supported by
CMemCache.
Note, there is no security measure to protected data in memcache. All data in memcache can be accessed by any process running in the system.
To use CMemCache as the cache application component, configure the application as follows,
array( 'components'=>array( 'cache'=>array( 'class'=>'CMemCache', 'servers'=>array( array( 'host'=>'server1', 'port'=>11211, 'weight'=>60, ), array( 'host'=>'server2', 'port'=>11211, 'weight'=>40, ), ), ), ), )
In the above, two memcache servers are used: server1 and server2. You can configure more properties of every server, including: host, port, persistent, weight, timeout, retryInterval, status. See http://www.php.net/manual/en/function.memcache-addserver.php for more details.
CMemCache can also be used with memcached. To do so, set CMemCache::$useMemcached
to be true.
- CComponent
- CApplicationComponent implements IApplicationComponent
- CCache implements ICache, ArrayAccess
- CMemCache
Copyright: 2008-2013 Yii Software LLC
License: http://www.yiiframework.com/license/
Author: Qiang Xue <qiang.xue@gmail.com>
Since: 1.0
Located at x2engine/framework/caching/CMemCache.php
public
|
#
init( )
Initializes this application component. This method is required by the |
public
Memcache|Memcached
|
|
public
array
|
|
public
|
|
protected
string|boolean
|
|
protected
array
|
|
protected
boolean
|
|
protected
boolean
|
|
protected
boolean
|
#
deleteValue( string $key )
Deletes a value with the specified key from cache This is the implementation of the method declared in the parent class. |
protected
boolean
|
#
flushValues( )
Deletes all values from cache. This is the implementation of the method declared in the parent class. |
add(),
delete(),
flush(),
generateUniqueKey(),
get(),
mget(),
offsetExists(),
offsetGet(),
offsetSet(),
offsetUnset(),
set()
|
getIsInitialized()
|
public
boolean
|
$useMemcached | false |
$hashKey,
$keyPrefix,
$serializer
|
$behaviors
|
public
mixed
|
$memCache |
#
The memcache instance (or memcached if |
public
array
|
$servers |
#
List of memcache server configurations. Each element is a |
$isInitialized
|