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