Exemplo n.º 1
0
 public function load()
 {
     $this->item = unserialize(File::read($this->getPath()));
     if (!$this->item instanceof CacheItem) {
         $this->item = null;
         throw new CorruptedDataException();
     }
 }
Exemplo n.º 2
0
 private function createCache()
 {
     $lineNumber = 1;
     $pos = [0];
     $handler = $this->handler->getFileHandler();
     while (fgets($handler, 8196) !== false) {
         if ($lineNumber % $this->pageSize === 0) {
             $pos[] = ftell($handler);
         }
         $lineNumber++;
     }
     if (count($pos) === 1) {
         $this->pageSize = $lineNumber - 1;
     }
     array_push($pos, File::size($this->getFileName()));
     $item = new CacheItem($pos, File::modTime($this->getFileName()), $this->pageSize);
     $this->cache->create($item);
 }