lithium\storage\cache\adapter\File::write()

public method

Write values to the cache. All items to be cached will receive an expiration time of $expiry.

Parameters

  • array $keys

    Key/value pairs with keys to uniquely identify the to-be-cached item.

  • string|integer $expiry

    A strtotime() compatible cache time or TTL in seconds. To persist an item use \lithium\storage\Cache::PERSIST.

Returns

boolean

true on successful write, false otherwise.

Source

	public function write(array $keys, $expiry = null) {
		$expiry = $expiry || $expiry === Cache::PERSIST ? $expiry : $this->_config['expiry'];

		if (!$expiry || $expiry === Cache::PERSIST) {
			$expires = 0;
		} elseif (is_int($expiry)) {
			$expires = $expiry + time();
		} else {
			$expires = strtotime($expiry);
		}
		if ($this->_config['scope']) {
			$keys = $this->_addScopePrefix($this->_config['scope'], $keys, '_');
		}
		foreach ($keys as $key => $value) {
			if (!$this->_write($key, $value, $expires)) {
				return false;
			}
		}
		return true;
	}