-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathPrefixedCacheItem.php
More file actions
71 lines (56 loc) · 1.4 KB
/
Copy pathPrefixedCacheItem.php
File metadata and controls
71 lines (56 loc) · 1.4 KB
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<?php
/*
* This file is part of php-cache organization.
*
* (c) 2015 Aaron Scherer <aequasi@gmail.com>, Tobias Nyholm <tobias.nyholm@gmail.com>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/
namespace Cache\Prefixed;
use Psr\Cache\CacheItemInterface;
/** @internal */
class PrefixedCacheItem implements CacheItemInterface
{
public function __construct(
private readonly string $key,
private readonly CacheItemInterface $item,
private readonly object $owner,
) {
}
public function unwrap(): CacheItemInterface
{
return $this->item;
}
public function isOwnedBy(object $owner): bool
{
return $this->owner === $owner;
}
public function getKey(): string
{
return $this->key;
}
public function get(): mixed
{
return $this->item->get();
}
public function isHit(): bool
{
return $this->item->isHit();
}
public function set(mixed $value): static
{
$this->item->set($value);
return $this;
}
public function expiresAt(?\DateTimeInterface $expiration): static
{
$this->item->expiresAt($expiration);
return $this;
}
public function expiresAfter(int|\DateInterval|null $time): static
{
$this->item->expiresAfter($time);
return $this;
}
}