Example #1
0
 /**
  * Enable cache. If $cache is file:/path/cache/file.ser load
  * serialized cache file ( { file_path1 = [md5, size, since], ... }).
  *
  * @throws 
  * @param string $cache
  */
 public function useCache($cache)
 {
     if (count($this->cache) > 0) {
         throw new Exception('cache was already loaded');
     }
     if (mb_substr($cache, 0, 5) === 'file:') {
         $this->conf['use_cache'] = $cache;
         $this->cache = [];
         $cache_file = mb_substr($cache, 5);
         if ($cache_file && File::exists($cache_file)) {
             $this->cache = File::unserialize($cache_file);
         }
     } else {
         throw new Exception('invalid cache', $cache);
     }
 }