public function cacheContent()

in lib/php/libsdk/SDK/Cache.php [50:76]


	public function cacheContent(string $path, string $content, bool $relative = false) : void
	{/*{{{*/
		$p = $this->getCacheablePath($path, $relative);

		$to_write = strlen($content);
		$wrote = 0;

		$fd = fopen($p, "wb");

		flock($fd, LOCK_EX);

		do {
			$got = fwrite($fd, substr($content, $wrote));
			if (false === $got) {
				break;
			}
			$wrote += $got;
		} while ($wrote < $to_write);

		flock($fd, LOCK_UN);

		fclose($fd);

		if ($to_write !== $wrote) {
			throw new Exception("Couldn't cache '$p'");
		}
	}/*}}}*/