10db5771eSMichael Große<?php 20db5771eSMichael Große 30db5771eSMichael Großenamespace dokuwiki\Cache; 40db5771eSMichael Große 50db5771eSMichael Große/** 60db5771eSMichael Große * Caching of parser instructions 70db5771eSMichael Große */ 80db5771eSMichael Großeclass CacheInstructions extends \dokuwiki\Cache\CacheParser 90db5771eSMichael Große{ 100db5771eSMichael Große 110db5771eSMichael Große /** 120db5771eSMichael Große * @param string $id page id 130db5771eSMichael Große * @param string $file source file for cache 140db5771eSMichael Große */ 150db5771eSMichael Große public function __construct($id, $file) 160db5771eSMichael Große { 170db5771eSMichael Große parent::__construct($id, $file, 'i'); 180db5771eSMichael Große } 190db5771eSMichael Große 200db5771eSMichael Große /** 210db5771eSMichael Große * retrieve the cached data 220db5771eSMichael Große * 230db5771eSMichael Große * @param bool $clean true to clean line endings, false to leave line endings alone 240db5771eSMichael Große * @return array cache contents 250db5771eSMichael Große */ 260db5771eSMichael Große public function retrieveCache($clean = true) 270db5771eSMichael Große { 280db5771eSMichael Große $contents = io_readFile($this->cache, false); 290db5771eSMichael Große return !empty($contents) ? unserialize($contents) : array(); 300db5771eSMichael Große } 310db5771eSMichael Große 320db5771eSMichael Große /** 330db5771eSMichael Große * cache $instructions 340db5771eSMichael Große * 350db5771eSMichael Große * @param array $instructions the instruction to be cached 360db5771eSMichael Große * @return bool true on success, false otherwise 370db5771eSMichael Große */ 380db5771eSMichael Große public function storeCache($instructions) 390db5771eSMichael Große { 40b4b0b31bSMichael Große if ($this->_nocache) { 410db5771eSMichael Große return false; 420db5771eSMichael Große } 430db5771eSMichael Große 44*033eb35bSkalenpw return io_saveFile($this->cache, serialize($instructions)); 450db5771eSMichael Große } 460db5771eSMichael Große} 47