1 | <?php |
||
30 | class CacheItem extends ObjectAbstract implements CacheItemExtendedInterface |
||
31 | { |
||
32 | /** |
||
33 | * cache pool |
||
34 | * |
||
35 | * @var CachePool |
||
36 | * @access protected |
||
37 | */ |
||
38 | protected $pool; |
||
39 | |||
40 | /** |
||
41 | * item key |
||
42 | * |
||
43 | * @var string |
||
44 | * @access protected |
||
45 | */ |
||
46 | protected $key; |
||
47 | |||
48 | /** |
||
49 | * flag for cache hit |
||
50 | * |
||
51 | * @var bool |
||
52 | * @access protected |
||
53 | */ |
||
54 | protected $hit; |
||
55 | |||
56 | /** |
||
57 | * flag for got value already |
||
58 | * |
||
59 | * @var bool |
||
60 | * @access protected |
||
61 | */ |
||
62 | protected $got = false; |
||
63 | |||
64 | /** |
||
65 | * Item exact value |
||
66 | * |
||
67 | * @var mixed |
||
68 | * @access protected |
||
69 | */ |
||
70 | protected $value; |
||
71 | |||
72 | /** |
||
73 | * Processed item value |
||
74 | * |
||
75 | * @var string |
||
76 | * @access protected |
||
77 | */ |
||
78 | protected $strval; |
||
79 | |||
80 | /** |
||
81 | * default expiration timestamp in seconds |
||
82 | * |
||
83 | * - 0 for no expiration |
||
84 | * |
||
85 | * - max value is 0x7fffffff |
||
86 | * |
||
87 | * @var int |
||
88 | * @access protected |
||
89 | */ |
||
90 | protected $expire = 0; |
||
91 | |||
92 | /** |
||
93 | * default TTL in seconds |
||
94 | * |
||
95 | * @var int |
||
96 | * @access protected |
||
97 | */ |
||
98 | protected $ttl = 28800; |
||
99 | |||
100 | /** |
||
101 | * Constructor |
||
102 | * |
||
103 | * @param string $key |
||
104 | * @param CachePool $pool |
||
105 | * @param array $properties optional properties |
||
106 | * @access public |
||
107 | */ |
||
108 | public function __construct( |
||
117 | |||
118 | /** |
||
119 | * {@inheritDoc} |
||
120 | */ |
||
121 | public function getKey() |
||
125 | |||
126 | /** |
||
127 | * {@inheritDoc} |
||
128 | */ |
||
129 | public function get() |
||
141 | |||
142 | /** |
||
143 | * {@inheritDoc} |
||
144 | */ |
||
145 | public function isHit() |
||
153 | |||
154 | /** |
||
155 | * {@inheritDoc} |
||
156 | */ |
||
157 | public function set($value) |
||
167 | |||
168 | /** |
||
169 | * {@inheritDoc} |
||
170 | */ |
||
171 | public function expiresAt($expiration) |
||
182 | |||
183 | /** |
||
184 | * {@inheritDoc} |
||
185 | */ |
||
186 | public function expiresAfter($time) |
||
199 | |||
200 | /** |
||
201 | * {@inheritDoc} |
||
202 | */ |
||
203 | public function getExpiration()/*# : \DateTime */ |
||
212 | |||
213 | /** |
||
214 | * {@inheritDoc} |
||
215 | */ |
||
216 | public function setStrVal($strval) |
||
221 | |||
222 | /** |
||
223 | * {@inheritDoc} |
||
224 | */ |
||
225 | public function getStrVal() |
||
229 | |||
230 | /** |
||
231 | * {@inheritDoc} |
||
232 | */ |
||
233 | public function __toString()/*# : string */ |
||
243 | |||
244 | /** |
||
245 | * Set hit status |
||
246 | * |
||
247 | * @param bool $hit |
||
248 | * @return bool current hit status |
||
249 | * @access protected |
||
250 | */ |
||
251 | protected function setHit(/*# bool */ $hit)/*# : bool */ |
||
256 | |||
257 | /** |
||
258 | * Get value from the cache pool |
||
259 | * |
||
260 | * @return mixed |
||
261 | * @access protected |
||
262 | */ |
||
263 | protected function getValue() |
||
282 | |||
283 | /** |
||
284 | * Convert $this->strval to $this->value if not yet |
||
285 | * |
||
286 | * @return mixed |
||
287 | * @access protected |
||
288 | */ |
||
289 | protected function postGetValue() |
||
297 | |||
298 | /** |
||
299 | * Get hit status from driver |
||
300 | * |
||
301 | * @return bool |
||
302 | * @access protected |
||
303 | */ |
||
304 | protected function hasHit()/*# : bool */ |
||
323 | |||
324 | /** |
||
325 | * Trigger cache pool event |
||
326 | * |
||
327 | * @param string $eventName |
||
328 | * @return bool |
||
329 | * @access protected |
||
330 | */ |
||
331 | protected function trigger(/*# string */ $eventName)/*# : bool */ |
||
335 | } |
||
336 |