1 | <?php |
||
17 | class OpcacheProxy implements ProxyInterface |
||
18 | { |
||
19 | /** |
||
20 | * @var AbstractAdapter |
||
21 | */ |
||
22 | protected $adapter; |
||
23 | |||
24 | /** |
||
25 | * {@inheritdoc} |
||
26 | */ |
||
27 | 15 | public function getFunctions() |
|
40 | |||
41 | /** |
||
42 | * {@inheritdoc} |
||
43 | */ |
||
44 | 15 | public function setAdapter(AbstractAdapter $adapter) |
|
48 | |||
49 | /** |
||
50 | * Compiles and caches a PHP script without executing it |
||
51 | * |
||
52 | * This function compiles a PHP script and adds it to the opcode cache without executing it. This can be used to |
||
53 | * prime the cache after a Web server restart by pre-caching files that will be included in later requests. |
||
54 | * |
||
55 | * @since 5.5.5 |
||
56 | * @since 7.0.2 |
||
57 | * @param string $file The path to the PHP script to be compiled. |
||
58 | * @return boolean Returns TRUE if file was compiled successfully or FALSE on failure. |
||
59 | */ |
||
60 | 1 | public function opcache_compile_file($file) |
|
70 | |||
71 | /** |
||
72 | * Compiles and caches a PHP scripts without executing them |
||
73 | * |
||
74 | * This function compiles a PHP scripts and adds them to the opcode cache without executing them. This can be used to |
||
75 | * prime the cache after a Web server restart by pre-caching files that will be included in later requests. |
||
76 | * |
||
77 | * @since 5.5.5 |
||
78 | * @since 7.0.2 |
||
79 | * @param array $files The array for paths to PHP scripts to be compiled. |
||
80 | * @return boolean Returns TRUE if files were compiled successfully or FALSE on failure. |
||
81 | */ |
||
82 | 1 | public function opcache_compile_files($files) |
|
83 | { |
||
84 | 1 | $code = new Code(); |
|
85 | 1 | $code->addStatement('$paths = ['); |
|
86 | 1 | foreach ($files as $file) { |
|
87 | 1 | $code->addStatement(sprintf(' %s,', var_export($file, true))); |
|
88 | } |
||
89 | |||
90 | 1 | $code->addStatement('];'); |
|
91 | |||
92 | 1 | $code->addStatements([ |
|
93 | 1 | 'foreach ($paths as $path) {', |
|
94 | ' $compiled = opcache_compile_file($path);', |
||
95 | ' if (!$compiled) {', |
||
96 | ' return false;', |
||
97 | ' }', |
||
98 | '}', |
||
99 | ]); |
||
100 | |||
101 | 1 | $code->addStatement('return true;'); |
|
102 | |||
103 | 1 | return $this->adapter->run($code); |
|
104 | } |
||
105 | |||
106 | /** |
||
107 | * Get configuration information about the cache |
||
108 | * |
||
109 | * @since 5.5.5 |
||
110 | * @since 7.0.2 |
||
111 | * @return array Returns an array of information, including ini, blacklist and version |
||
112 | */ |
||
113 | 2 | public function opcache_get_configuration() |
|
120 | |||
121 | /** |
||
122 | * Get status information about the cache |
||
123 | * |
||
124 | * @since 5.5.5 |
||
125 | * @since 7.0.2 |
||
126 | * @param boolean $get_scripts Include script specific state information |
||
127 | * @return array Returns an array of information, optionally containing script specific state |
||
128 | * information |
||
129 | */ |
||
130 | 3 | public function opcache_get_status($get_scripts = true) |
|
140 | |||
141 | /** |
||
142 | * Get status information about the cache |
||
143 | * |
||
144 | * @since 5.5.0 |
||
145 | * @since 7.0.0 |
||
146 | * @param string $script The path to the script being invalidated. |
||
147 | * @param boolean $force If set to TRUE, the script will be invalidated regardless of whether invalidation is |
||
148 | * necessary. |
||
149 | * @return boolean Returns TRUE if the opcode cache for script was invalidated or if there was nothing to |
||
150 | * invalidate, or FALSE if the opcode cache is disabled. |
||
151 | */ |
||
152 | 1 | public function opcache_invalidate($script, $force = false) |
|
163 | |||
164 | /** |
||
165 | * Resets the contents of the opcode cache |
||
166 | * |
||
167 | * @since 5.5.0 |
||
168 | * @since 7.0.0 |
||
169 | * @return boolean Returns TRUE if the opcode cache was reset, or FALSE if the opcode cache is disabled. |
||
170 | */ |
||
171 | 2 | public function opcache_reset() |
|
181 | |||
182 | /** |
||
183 | * @return string |
||
184 | */ |
||
185 | 1 | public function opcache_version() |
|
192 | } |
||
193 |