You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

46 lines
1.0 KiB

  1. <?php
  2. namespace dokuwiki\Cache;
  3. /**
  4. * Caching of parser instructions
  5. */
  6. class CacheInstructions extends CacheParser
  7. {
  8. /**
  9. * @param string $id page id
  10. * @param string $file source file for cache
  11. */
  12. public function __construct($id, $file)
  13. {
  14. parent::__construct($id, $file, 'i');
  15. }
  16. /**
  17. * retrieve the cached data
  18. *
  19. * @param bool $clean true to clean line endings, false to leave line endings alone
  20. * @return array cache contents
  21. */
  22. public function retrieveCache($clean = true)
  23. {
  24. $contents = io_readFile($this->cache, false);
  25. return empty($contents) ? [] : unserialize($contents);
  26. }
  27. /**
  28. * cache $instructions
  29. *
  30. * @param array $instructions the instruction to be cached
  31. * @return bool true on success, false otherwise
  32. */
  33. public function storeCache($instructions)
  34. {
  35. if ($this->_nocache) {
  36. return false;
  37. }
  38. return io_saveFile($this->cache, serialize($instructions));
  39. }
  40. }