summaryrefslogtreecommitdiff
path: root/vendor/doctrine/orm/src/Cache/QueryCacheEntry.php
blob: 1e39262b92d82ca85ab27a44cf81b3e9574f0a47 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
<?php

declare(strict_types=1);

namespace Doctrine\ORM\Cache;

use function microtime;

class QueryCacheEntry implements CacheEntry
{
    /**
     * Time creation of this cache entry
     */
    public readonly float $time;

    /** @param array<string, mixed> $result List of entity identifiers */
    public function __construct(
        public readonly array $result,
        float|null $time = null,
    ) {
        $this->time = $time ?: microtime(true);
    }

    /** @param array<string, mixed> $values */
    public static function __set_state(array $values): self
    {
        return new self($values['result'], $values['time']);
    }
}