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:----v2m84Cs/xE46T8ctBjYfQNdDBORbll7YTWcjHc/OKYOlShRm4e9z/cnli1tYElIr+U94IO2l2E0IM+YkDEYyh8HUMM1p17xMGG9zvmqW2UFizcxfr+xUZe2auELbBoFEjLKJM+ebG4d18LNBckrn1+o24/ODZ4CuO/IkXVaCir7602z/l2xUNWTDrJjrXdM/oCUzC9fZczoLQ/Z6jlmQHiv498KkYjLiT+Dl4fbnWpmgc2uoJK2LZbi4rK64WxFv6v4gxuHINHQDjknBR3IjncBhMR4wgFUxqOoOlgNdSsi4JbfXLVVAJgN348x6lUZTF+zZoVPw8hqo/gEjgEhaZQoXsLHDdOUrFyEQxzCYor1LTAg0s6G2nI4Vgd2qhBvxqEbp/YMRoG9v65BzHVKLSdQK2el4GPAi8fK+zzWva86Fm24+oXteuuVZbJWdqxSXR9HNdVRZu1A8qY0ZuN5GWCAr+KV2DrbBwhmAa3ZtItsHoRSt1K+m6AKsqEw0Fn9UtD5850FFsmmbN7zfdFJ5RX98Lvd1qMyxJ4jKcq0W/YbrJD7cI+5pJiLzNpZO5wbs56tILcZZWimMoU8tokYiwpG6+PHNOlolt/AqGUyWaaZVSBqMfR1p4l8KOPU2X19WoJipNFeJW9IT7sCkeV4U21L1Kgwkqb7rHbmML3wjTL8=----ATTACHMENT:----MjkwMDgxOTcyNDE2NTExNCAyNzcxMDI4Mjg4MDQ3MzAyIDgxNDIyNzAwOTk4MzcwOTQ=