1 | <?php |
||
15 | trait HandlerTrait |
||
16 | { |
||
17 | use ConfigAwareTrait; |
||
18 | use LoggerAwareTrait; |
||
19 | |||
20 | |||
21 | /** |
||
22 | * Compute expiration timestamp |
||
23 | * |
||
24 | * @param int $lifetime Length, in seconds |
||
25 | * @param int $startTime Start timestamp, default use time() |
||
26 | * @return int End timestamp or 0 for never expire |
||
27 | */ |
||
28 | protected function computeExpireTime($lifetime = null, $startTime = 0) |
||
46 | |||
47 | |||
48 | /** |
||
49 | * Get lifetime length, in seconds |
||
50 | * |
||
51 | * For solid lifetime length, define them in configs. |
||
52 | * For dynamic lifetime length, overwrite this method to compute it. |
||
53 | * |
||
54 | * This implement will return 0 if config not set, means never expire. |
||
55 | * |
||
56 | * @param string $key |
||
57 | * @return int |
||
58 | */ |
||
59 | protected function getLifetime($key = null) |
||
65 | |||
66 | |||
67 | /** |
||
68 | * Convert required key to actual key inner used |
||
69 | * |
||
70 | * In some cache system, key may need manual hashed. |
||
71 | * |
||
72 | * @param string $key |
||
73 | * @return string |
||
74 | */ |
||
75 | protected function hashKey($key) |
||
88 | } |
||
89 |
In PHP, under loose comparison (like
==
, or!=
, orswitch
conditions), values of different types might be equal.For
string
values, the empty string''
is a special case, in particular the following results might be unexpected: