Write value(s) to the cache.

Parameters

  • string $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) {
		$path = $this->_config['path'];
		$expiry = ($expiry) ?: $this->_config['expiry'];

		return function($self, $params) use (&$path, $expiry) {
			$expiry = strtotime($expiry);
			$data = "{:expiry:{$expiry}}\n{$params['data']}";
			$path = "{$path}/{$params['key']}";
			return file_put_contents($path, $data);
		};
	}