lithium\storage\cache\adapter\Memcache::__construct()
Overrides
lithium\core\Object::__construct()
Constructor. Instantiates the Memcached
object, adds appropriate servers to the pool,
and configures any optional settings passed (see the _init()
method). When adding
servers, the following formats are valid for the 'host'
key:
'127.0.0.1'
Configure the adapter to connect to one Memcache server on the default port.'127.0.0.1:11222'
Configure the adapter to connect to one Memcache server on a custom port.array('167.221.1.5:11222' => 200, '167.221.1.6')
Connect to one server on a custom port with a high selection weight, and a second server on the default port with the default selection weight.
Parameters
-
array
$config
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 astrtotime()
compatible tring or TTL in seconds. To indicate items should not expire useCache::PERSIST
. Defaults to+1 hour
.'host'
mixed: Specifies one or more Memcache servers to connect to, with optional server selection weights. See above for example values.
Returns
voidSource
public function __construct(array $config = array()) {
$defaults = array(
'scope' => null,
'expiry' => '+1 hour',
'host' => '127.0.0.1'
);
parent::__construct(Set::merge($defaults, $config));
}