Exception
9 months ago
Logging
9 months ago
Persister
9 months ago
Region
9 months ago
AssociationCacheEntry.php
9 months ago
CacheConfiguration.php
9 months ago
CacheEntry.php
9 months ago
CacheException.php
9 months ago
CacheFactory.php
9 months ago
CacheKey.php
9 months ago
CollectionCacheEntry.php
9 months ago
CollectionCacheKey.php
9 months ago
CollectionHydrator.php
9 months ago
ConcurrentRegion.php
9 months ago
DefaultCache.php
9 months ago
DefaultCacheFactory.php
9 months ago
DefaultCollectionHydrator.php
9 months ago
DefaultEntityHydrator.php
9 months ago
DefaultQueryCache.php
9 months ago
EntityCacheEntry.php
9 months ago
EntityCacheKey.php
9 months ago
EntityHydrator.php
9 months ago
Lock.php
9 months ago
LockException.php
9 months ago
MultiGetRegion.php
9 months ago
QueryCache.php
9 months ago
QueryCacheEntry.php
9 months ago
QueryCacheKey.php
9 months ago
QueryCacheValidator.php
9 months ago
Region.php
9 months ago
RegionsConfiguration.php
9 months ago
TimestampCacheEntry.php
9 months ago
TimestampCacheKey.php
9 months ago
TimestampQueryCacheValidator.php
9 months ago
TimestampRegion.php
9 months ago
index.php
9 months ago
TimestampQueryCacheValidator.php
32 lines
| 1 | <?php |
| 2 | declare (strict_types=1); |
| 3 | namespace MailPoetVendor\Doctrine\ORM\Cache; |
| 4 | if (!defined('ABSPATH')) exit; |
| 5 | use function microtime; |
| 6 | class TimestampQueryCacheValidator implements QueryCacheValidator |
| 7 | { |
| 8 | private $timestampRegion; |
| 9 | public function __construct(TimestampRegion $timestampRegion) |
| 10 | { |
| 11 | $this->timestampRegion = $timestampRegion; |
| 12 | } |
| 13 | public function isValid(QueryCacheKey $key, QueryCacheEntry $entry) |
| 14 | { |
| 15 | if ($this->regionUpdated($key, $entry)) { |
| 16 | return \false; |
| 17 | } |
| 18 | if ($key->lifetime === 0) { |
| 19 | return \true; |
| 20 | } |
| 21 | return $entry->time + $key->lifetime > microtime(\true); |
| 22 | } |
| 23 | private function regionUpdated(QueryCacheKey $key, QueryCacheEntry $entry) : bool |
| 24 | { |
| 25 | if ($key->timestampKey === null) { |
| 26 | return \false; |
| 27 | } |
| 28 | $timestamp = $this->timestampRegion->get($key->timestampKey); |
| 29 | return $timestamp && $timestamp->time > $entry->time; |
| 30 | } |
| 31 | } |
| 32 |