Extends
lithium\core\Object
Write value(s) to the cache.
This adapter method supports multi-key write. By specifying `$key` as an
associative array of key/value pairs, `$data` is ignored and all keys that
are cached will receive an expiration time of `$expiry`.
Parameters
- string|array $key The key to uniquely identify the cached item.
- mixed $data The value to be cached.
- null|string $expiry A strtotime() compatible cache time. If no expiry time is set, then the default cache expiration time set with the cache configuration will be used.
Returns
closure Function returning boolean `true` on successful write, `false` otherwise.Source
public function write($key, $data, $expiry = null) {
$expiry = ($expiry) ?: $this->_config['expiry'];
return function($self, $params) use ($expiry) {
$cachetime = (is_int($expiry) ? $expiry : strtotime($expiry)) - time();
$key = $params['key'];
if (is_array($key)) {
return apc_store($key, $cachetime);
}
return apc_store($params['key'], $params['data'], $cachetime);
};
}