Reads from the specified cache configuration

Parameters

  • string $name Configuration to be used for reading
  • mixed $key Key to be retrieved
  • mixed $options Options for the method and strategies.

Returns

mixed Read results on successful cache read, null otherwise
This method can be filtered.

Source

						public static function read($name, $key, array $options = array()) {
		$options += array('conditions' => null, 'strategies' => true, 'write' => null);
		$settings = static::config();

		if (!isset($settings[$name])) {
			return false;
		}
		$conditions = $options['conditions'];

		if (is_callable($conditions) && !$conditions()) {
			return false;
		}
		$key = static::key($key);
		$method = static::adapter($name)->read($key);
		$params = compact('key');
		$filters = $settings[$name]['filters'];
		$result = static::_filter(__FUNCTION__, $params, $method, $filters);

		if ($result === null && ($write = $options['write'])) {
			$write = is_callable($write) ? $write() : $write;
			list($expiry, $value) = each($write);
			$value = is_callable($value) ? $value() : $value;

			if (static::write($name, $key, $value, $expiry)) {
				$result = $value;
			}
		}

		if ($options['strategies']) {
			$options = compact('key') + array('mode' => 'LIFO', 'class' => __CLASS__);
			$result = static::applyStrategies(__FUNCTION__, $name, $result, $options);
		}
		return $result;
	}