1 | <?php |
||
30 | class Cache extends AbstractHelper |
||
31 | { |
||
32 | /** |
||
33 | * @var string |
||
34 | */ |
||
35 | protected $prefix; |
||
36 | |||
37 | /** |
||
38 | * @var \Xoops\Core\Cache\Access |
||
39 | */ |
||
40 | protected $cache; |
||
41 | |||
42 | /** |
||
43 | * Initialize parent::__constuct calls this after verifying module object. |
||
44 | * |
||
45 | * @return void |
||
46 | */ |
||
47 | public function init() |
||
52 | |||
53 | /** |
||
54 | * Add our module prefix to a name |
||
55 | * |
||
56 | * @param string $name name to prefix |
||
57 | * |
||
58 | * @return string module prefixed name |
||
59 | */ |
||
60 | protected function prefix($name) |
||
64 | |||
65 | /** |
||
66 | * Write a value for a key to the cache |
||
67 | * |
||
68 | * @param string $key Identifier for the data |
||
69 | * @param mixed $value Data to be cached - anything except a resource |
||
70 | * @param int|DateTime|null $ttl Time to live, integer for ttl in seconds, |
||
71 | * DateTime object to expire at a specific time, |
||
72 | * or null for |
||
73 | * |
||
74 | * @return bool True if the data was successfully cached, false on failure |
||
75 | */ |
||
76 | public function write($key, $value, $ttl = null) |
||
80 | |||
81 | /** |
||
82 | * Read value for a key from the cache |
||
83 | * |
||
84 | * @param string $key Identifier for the data |
||
85 | * @param mixed $default default value to return if config $key is not set |
||
86 | * |
||
87 | * @return mixed value if key was set, false not set or expired |
||
88 | */ |
||
89 | public function read($key, $default = false) |
||
94 | |||
95 | /** |
||
96 | * Delete a key from the cache |
||
97 | * |
||
98 | * @param string $key Identifier for the data |
||
99 | * |
||
100 | * @return void |
||
101 | */ |
||
102 | public function delete($key) |
||
106 | |||
107 | /** |
||
108 | * cache block wrapper |
||
109 | * |
||
110 | * If the cache read for $key is a miss, call the $regenFunction to update it. |
||
111 | * With the PRECOMPUTE strategy, it will trigger a miss on a read on one caller |
||
112 | * before the cache expires, so it will be done in advance. |
||
113 | * |
||
114 | * @param string|string[] $cacheKey Identifier for the cache item |
||
115 | * @param callable $regenFunction function to generate cached content |
||
116 | * @param int|DateTime|null $ttl time to live, number ofseconds as integer, |
||
117 | * DateTime to expire at a specific time, |
||
118 | * or null for default |
||
119 | * @param mixed ...$args variable argument list for $regenFunction |
||
120 | * |
||
121 | * @return mixed |
||
122 | */ |
||
123 | public function cacheRead($cacheKey, $regenFunction, $ttl = null, $args = null) |
||
127 | |||
128 | /** |
||
129 | * clear all keys and data from the module's cache. This will do a hierarchical |
||
130 | * delete on our module specific prefix. |
||
131 | * |
||
132 | * @return boolean True if the cache was successfully cleared, false otherwise |
||
133 | */ |
||
134 | public function clear() |
||
138 | } |
||
139 |
This check looks at variables that have been passed in as parameters and are passed out again to other methods.
If the outgoing method call has stricter type requirements than the method itself, an issue is raised.
An additional type check may prevent trouble.