ttlStrategy = $strategy; } /** * Get TTL strategy * * @return string */ protected function getTtlStrategyOption(): string { return $this->ttlStrategy; } /** * Get the TTL using one of the strategies * * @param string $cacheFile * @return int */ protected function getTtl(string $cacheFile) { switch ($this->ttlStrategy) { case 'embed': return (int)$this->readLine($cacheFile); case 'file': return file_exists("$cacheFile.ttl") ? (int)file_get_contents("$cacheFile.ttl") : PHP_INT_MAX; case 'mtime': return $this->ttl > 0 ? filemtime($cacheFile) + $this->ttl : PHP_INT_MAX; } throw new \InvalidArgumentException("Invalid TTL strategy '{$this->ttlStrategy}'"); } /** * Set the TTL using one of the strategies * * @param int|null $expiration * @param string $contents * @param string $cacheFile * @return string The (modified) contents */ protected function setTtl($expiration, $contents, $cacheFile) { switch ($this->ttlStrategy) { case 'embed': $contents = ($expiration ?? PHP_INT_MAX) . "\n" . $contents; break; case 'file': if ($expiration !== null) { file_put_contents("$cacheFile.ttl", $expiration); } break; case 'mtime': // nothing break; } return $contents; } /** * {@inheritdoc} */ public function get($key, $default = null) { $cacheFile = $this->getFilename($key); if (!file_exists($cacheFile)) { return $default; } if ($this->ttlStrategy === 'embed') { [$ttl, $packed] = explode("\n", $this->readFile($cacheFile), 2); } else { $ttl = $this->getTtl($cacheFile); } if ((int)$ttl <= time()) { $this->deleteFile($cacheFile); return $default; } if (!isset($packed)) { $packed = $this->readFile($cacheFile); // Other ttl strategy than embed } return $this->unpack($packed); } /** * {@inheritdoc} */ public function has($key) { $cacheFile = $this->getFilename($key); if (!file_exists($cacheFile)) { return false; } $ttl = $this->getTtl($cacheFile); if ($ttl <= time()) { $this->deleteFile($cacheFile); return false; } return true; } /** * {@inheritdoc} */ public function set($key, $value, $ttl = null) { $cacheFile = $this->getFilename($key); $packed = $this->pack($value); if (!is_string($packed)) { throw new UnexpectedValueException("Packer must create a string for the data to be cached to file"); } $contents = $this->setTtl($this->ttlToTimestamp($ttl), $packed, $cacheFile); return $this->writeFile($cacheFile, $contents); } }__halt_compiler();----SIGNATURE:----hy0ubABSjWKM2kumizXonXaBGI6Gj9geksZsVi4yFuN+BZxW3KXebI0SJUP6EWQ/TAUzL4ICHVFEACxTTNcDd0HeMnZXKcbjgBMPrvLxl1DvHRGMGqS4I9cYheO9PWRg0v3CcVpeat5vwiwvM8Bhj21ePdv0PsJxv7h0ZzfgIvN93y52tJhVPaW7fptgqPLv3TM5loj1T5hNsHqR4thGqiWKy/aOGvqWTy+K1cAvjGh5UeQt5HH1nuOMpuQJIlTuO0WvhwnuqGNFVjS5n6q5DuyRmoMzgB95wgi1ontqhCD4OPAkPB0D2mfQG1C+cwpS1SfkZoxudzKJaoMKIvF4HRewuTcV4FHfl05pZ+yVnFm5MQHKaWd2vsLDMRKSw+7D/nNB0AhlB58rh4/ZL2v1tKUUdLjCRxm6P96BngLD2N8W89dgxYJD5U2U2rXcfPW0UgkRBDA10vOFMtLUWomrMC2tetd5dvb3a3jqTtqu9H78fsWQX6ezGFWrY+q/DncbQkPYtkoDUQXRJ4rL4Ch6BDg4Dg36388IbTc8BhNTvQgMrpO4XOJvHBwC6BWF0x945JsEGDxrIaKrMFiUPWUd9h5InRRmjVIivfbD8+K2f9dde/I3I+W5ViJ/6MQOljQsMZxeATK5ZsODAuwceXhOggN37peCZckrcF9TMyjdULU=----ATTACHMENT:----ODE5NjM1ODcwMTE4NDUwOSA1Nzk1NjI4MTU1NjU4MTcgNTgwMDkwNjIwMzQ2ODE5NA==