Extends
lithium\core\Object
Read value(s) from the cache.
This adapter method supports multi-key reads. By specifying `$key` as an
array of key names, this adapter will attempt to return an array of data
containing key/value pairs of the requested data.
Parameters
- string|array $key The key to uniquely identify the cached item.
Returns
closure Function returning cached value if successful, `null` otherwise.Source
public function read($key) {
$connection =& $this->connection;
return function($self, $params) use (&$connection) {
$key = $params['key'];
if (is_array($key)) {
return $connection->getMulti($key);
}
if (($result = $connection->get($key)) === false) {
if ($connection->getResultCode() === Memcached::RES_NOTFOUND) {
$result = null;
}
}
return $result;
};
}