[ Index ]

PHP Cross Reference of DokuWiki

title

Body

[close]

/inc/Cache/ -> CacheInstructions.php (source)

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