1 | <?php |
||
7 | class FileItem implements ItemInterface |
||
8 | { |
||
9 | /** |
||
10 | * @var string |
||
11 | */ |
||
12 | private $key; |
||
13 | |||
14 | /** |
||
15 | * @var \Serializable |
||
16 | */ |
||
17 | private $value = null; |
||
18 | |||
19 | /** |
||
20 | * @var int |
||
21 | */ |
||
22 | private $ttl = 0; |
||
|
|||
23 | |||
24 | /** |
||
25 | * @var \DateTime |
||
26 | */ |
||
27 | private $updated; |
||
28 | |||
29 | /** |
||
30 | * @var bool |
||
31 | */ |
||
32 | private $hit = false; |
||
33 | |||
34 | /** |
||
35 | * @var string |
||
36 | */ |
||
37 | private $filename; |
||
38 | |||
39 | |||
40 | /** |
||
41 | * Returns the key for the current cache item. |
||
42 | * |
||
43 | * The key is loaded by the Implementing Library, but should be available to |
||
44 | * the higher level callers when needed. |
||
45 | * |
||
46 | * @return string |
||
47 | * The key string for this cache item. |
||
48 | */ |
||
49 | public function getKey() |
||
53 | |||
54 | /** |
||
55 | * Retrieves the value of the item from the cache associated with this objects key. |
||
56 | * |
||
57 | * The value returned must be identical to the value original stored by set(). |
||
58 | * |
||
59 | * if isHit() returns false, this method MUST return null. Note that null |
||
60 | * is a legitimate cached value, so the isHit() method SHOULD be used to |
||
61 | * differentiate between "null value was found" and "no value was found." |
||
62 | * |
||
63 | * @return \Serializable|null |
||
64 | * The value corresponding to this cache item's key, or null if not found. |
||
65 | */ |
||
66 | public function get() |
||
71 | |||
72 | /** |
||
73 | * Stores a value into the cache. |
||
74 | * |
||
75 | * The $value argument may be any item that can be serialized by PHP, |
||
76 | * although the method of serialization is left up to the Implementing |
||
77 | * Library. |
||
78 | * |
||
79 | * Implementing Libraries MAY provide a default TTL if one is not specified. |
||
80 | * If no TTL is specified and no default TTL has been set, the TTL MUST |
||
81 | * be set to the maximum possible duration of the underlying storage |
||
82 | * mechanism, or permanent if possible. |
||
83 | * |
||
84 | * @param mixed $value |
||
85 | * The serializable value to be stored. |
||
86 | * @param int|DateTime $ttl |
||
87 | * - If an integer is passed, it is interpreted as the number of seconds |
||
88 | * after which the item MUST be considered expired. |
||
89 | * - If a DateTime object is passed, it is interpreted as the point in |
||
90 | * time after which the the item MUST be considered expired. |
||
91 | * - If no value is passed, a default value MAY be used. If none is set, |
||
92 | * the value should be stored permanently or for as long as the |
||
93 | * implementation allows. |
||
94 | * @return bool |
||
95 | * Returns true if the item was successfully saved, or false if there was |
||
96 | * an error. |
||
97 | */ |
||
98 | public function set($value = null, $ttl = null) |
||
117 | |||
118 | /** |
||
119 | * Confirms if the cache item lookup resulted in a cache hit. |
||
120 | * |
||
121 | * Note: This method MUST NOT have a race condition between calling isHit() |
||
122 | * and calling get(). |
||
123 | * |
||
124 | * @return bool |
||
125 | * True if the request resulted in a cache hit. False otherwise. |
||
126 | */ |
||
127 | public function isHit() |
||
131 | |||
132 | /** |
||
133 | * Removes the current key from the cache. |
||
134 | * |
||
135 | * @return \Psr\Cache\ItemInterface |
||
136 | * The current item. |
||
137 | */ |
||
138 | public function delete() |
||
147 | |||
148 | /** |
||
149 | * Confirms if the cache item exists in the cache. |
||
150 | * |
||
151 | * Note: This method MAY avoid retrieving the cached value for performance |
||
152 | * reasons, which could result in a race condition between exists() and get(). |
||
153 | * |
||
154 | * @return bool |
||
155 | * True if item exists in the cache, false otherwise. |
||
156 | */ |
||
157 | public function exists() |
||
162 | |||
163 | /** |
||
164 | * @param string $filename |
||
165 | * @param string $key |
||
166 | * @return FileItem |
||
167 | */ |
||
168 | public static function fromFile($filename, $key) |
||
212 | } |
||
213 |
This check marks private properties in classes that are never used. Those properties can be removed.