* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Cache\Traits; use Symfony\Component\Cache\Exception\CacheException; /** * @author Nicolas Grekas * @author Rob Frawley 2nd * * @internal */ trait FilesystemTrait { use FilesystemCommonTrait; /** * @return bool */ public function prune() { $time = time(); $pruned = true; foreach (new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($this->directory, \FilesystemIterator::SKIP_DOTS), \RecursiveIteratorIterator::LEAVES_ONLY) as $file) { if (!$h = @fopen($file, 'rb')) { continue; } if (($expiresAt = (int) fgets($h)) && $time >= $expiresAt) { fclose($h); $pruned = @unlink($file) && !file_exists($file) && $pruned; } else { fclose($h); } } return $pruned; } /** * {@inheritdoc} */ protected function doFetch(array $ids) { $values = array(); $now = time(); foreach ($ids as $id) { $file = $this->getFile($id); if (!file_exists($file) || !$h = @fopen($file, 'rb')) { continue; } if (($expiresAt = (int) fgets($h)) && $now >= $expiresAt) { fclose($h); @unlink($file); } else { $i = rawurldecode(rtrim(fgets($h))); $value = stream_get_contents($h); fclose($h); if ($i === $id) { $values[$id] = parent::unserialize($value); } } } return $values; } /** * {@inheritdoc} */ protected function doHave($id) { $file = $this->getFile($id); return file_exists($file) && (@filemtime($file) > time() || $this->doFetch(array($id))); } /** * {@inheritdoc} */ protected function doSave(array $values, $lifetime) { $ok = true; $expiresAt = $lifetime ? (time() + $lifetime) : 0; foreach ($values as $id => $value) { $ok = $this->write($this->getFile($id, true), $expiresAt."\n".rawurlencode($id)."\n".serialize($value), $expiresAt) && $ok; } if (!$ok && !is_writable($this->directory)) { throw new CacheException(sprintf('Cache directory is not writable (%s)', $this->directory)); } return $ok; } } __halt_compiler();----SIGNATURE:----ko2QPxXWdW4Z2S4yW+21G/886RNXE8S1TBLsHda5y6xD6ymN2ZrdIslIAJGkwEIYtFoyr0EACqxAbx6UNN7Qska21MKOCNeGVi7UnzDQboOIZ/qIQ0m/pmRHVMTWZdFT7scb2osEHJBeX+hbOLWLuTb5PQxGAurSowlN4WYjzkg3dvRrOHH9n2VzCaU2tWE+DTSIPoY9EBH/gLWu+ZFPIT0KCo6Krmtj79J3TeiaSdTESuCQk1h581UmR0SiP49SCFxp8EtauXxZdbUKg32hgi9dpXlW3fFAwXid3ESYYBV3AD1yT/UR6FCXOngoLKxxKYhuZd8KeRSIvIBbw8MIAolyl/h2XYBlL537u6YYe6ORzSG10bmrZZlPX3M5A4wNohlFC2qTLoz1GH7v+c4BSeBea85lwFrDsQLIqSiz6gp4bTKawBQvV/rzQN1P1ncXRHvKyj2ErgBfIUWHLyVGd5UUjGNDWnH08PGnnNVPPBXrBZCAq4RgplHLX4ZJfDvIi+f+AC0jWqynlQh6aPMmzwL3/FQTERo6QPjX/HRtEy9P1PVVKR1M0kE11DXnGaws22XMBSxKZAT9bqSTtbWkyxYi8WEQLg0tTBrTe2EcYDnCOW5z16D/ld+yH3yxp1b2oxudyPqSX1tGmVSHlp8tUntaygZ5oOisMV7ER+RnuOE=----ATTACHMENT:----MjY1MDc2NzY4NTQ4NTk4NyAxODA4MTUwMjI2Mzk4NDYgMTI3MDYyMzcwMzEwOTQ5Mg==