1 | <?php |
||
9 | class MemoryCacheItem implements CacheItemInterface { |
||
10 | /** @var string **/ |
||
11 | protected $key; |
||
12 | /** @var mixed **/ |
||
13 | protected $value; |
||
14 | /** @var int **/ |
||
15 | protected $defaultLifetime = 3600; |
||
16 | /** @var \DateTime **/ |
||
17 | protected $expiresAt; |
||
18 | /** @var string **/ |
||
19 | protected $driver = 'memory'; |
||
20 | |||
21 | /** |
||
22 | * @param string $key |
||
23 | * @param int $ttl |
||
24 | */ |
||
25 | 20 | public function __construct($key, $ttl = null) { |
|
29 | |||
30 | /** |
||
31 | * {@inheritdoc} |
||
32 | */ |
||
33 | 8 | public function set($value) { |
|
38 | |||
39 | /** |
||
40 | * {@inheritdoc} |
||
41 | */ |
||
42 | 11 | public function isHit() { |
|
45 | |||
46 | /** |
||
47 | * {@inheritdoc} |
||
48 | */ |
||
49 | 14 | public function getKey() { |
|
52 | |||
53 | /** |
||
54 | * {@inheritdoc} |
||
55 | */ |
||
56 | 9 | public function get() { |
|
62 | |||
63 | /** |
||
64 | * {@inheritdoc} |
||
65 | */ |
||
66 | 20 | public function expiresAfter($time) { |
|
73 | |||
74 | /** |
||
75 | * {@inheritdoc} |
||
76 | */ |
||
77 | 2 | public function expiresAt($expiration) { |
|
78 | 2 | $this->expiresAt = |
|
79 | 2 | ($expiration === null) |
|
80 | ? (new \DateTime())->setTimestamp(time() + $this->defaultLifetime) |
||
81 | 2 | : $expiration |
|
82 | ; |
||
83 | 2 | return $this; |
|
84 | } |
||
85 | |||
86 | /** |
||
87 | * @return \DateTime |
||
88 | */ |
||
89 | 2 | public function getExpirationDate() { |
|
92 | |||
93 | /** |
||
94 | * @return string |
||
95 | */ |
||
96 | 2 | public function getDriver() { |
|
99 | } |
||
100 |