@@ -103,7 +103,6 @@ public function initialize(int $processId, ClientCapabilities $capabilities, str
103
103
104
104
// start building project index
105
105
if ($ rootPath !== null ) {
106
- $ this ->restoreCache ();
107
106
$ this ->indexProject ();
108
107
}
109
108
@@ -135,9 +134,6 @@ public function initialize(int $processId, ClientCapabilities $capabilities, str
135
134
*/
136
135
public function shutdown ()
137
136
{
138
- if ($ this ->rootPath !== null ) {
139
- $ this ->saveCache ();
140
- }
141
137
}
142
138
143
139
/**
@@ -181,69 +177,14 @@ private function indexProject()
181
177
}
182
178
}
183
179
184
- if ($ fileNum % 1000 === 0 ) {
185
- $ this ->saveCache ();
186
- }
187
-
188
180
Loop \setTimeout ($ processFile , 0 );
189
181
} else {
190
182
$ duration = (int )(microtime (true ) - $ startTime );
191
183
$ mem = (int )(memory_get_usage (true ) / (1024 * 1024 ));
192
184
$ this ->client ->window ->logMessage (MessageType::INFO , "All PHP files parsed in $ duration seconds. $ mem MiB allocated. " );
193
- $ this ->saveCache ();
194
185
}
195
186
};
196
187
197
188
Loop \setTimeout ($ processFile , 0 );
198
189
}
199
-
200
- /**
201
- * Restores the definition and reference index from the .phpls cache directory, if available
202
- *
203
- * @return void
204
- */
205
- public function restoreCache ()
206
- {
207
- $ cacheDir = $ this ->rootPath . '/.phpls ' ;
208
- if (is_dir ($ cacheDir )) {
209
- if (file_exists ($ cacheDir . '/symbols ' )) {
210
- $ symbols = unserialize (file_get_contents ($ cacheDir . '/symbols ' ));
211
- $ count = count ($ symbols );
212
- $ this ->project ->setSymbols ($ symbols );
213
- $ this ->client ->window ->logMessage (MessageType::INFO , "Restoring $ count symbols " );
214
- }
215
- if (file_exists ($ cacheDir . '/references ' )) {
216
- $ references = unserialize (file_get_contents ($ cacheDir . '/references ' ));
217
- $ count = array_sum (array_map ('count ' , $ references ));
218
- $ this ->project ->setReferenceUris ($ references );
219
- $ this ->client ->window ->logMessage (MessageType::INFO , "Restoring $ count references " );
220
- }
221
- } else {
222
- $ this ->client ->window ->logMessage (MessageType::INFO , 'No cache found ' );
223
- }
224
- }
225
-
226
- /**
227
- * Saves the definition and reference index to the .phpls cache directory
228
- *
229
- * @return void
230
- */
231
- public function saveCache ()
232
- {
233
- // Cache definitions, references
234
- $ cacheDir = $ this ->rootPath . '/.phpls ' ;
235
- if (!is_dir ($ cacheDir )) {
236
- mkdir ($ cacheDir );
237
- }
238
-
239
- $ symbols = $ this ->project ->getSymbols ();
240
- $ count = count ($ symbols );
241
- $ this ->client ->window ->logMessage (MessageType::INFO , "Saving $ count symbols to cache " );
242
- file_put_contents ($ cacheDir . "/symbols " , serialize ($ symbols ));
243
-
244
- $ references = $ this ->project ->getReferenceUris ();
245
- $ count = array_sum (array_map ('count ' , $ references ));
246
- $ this ->client ->window ->logMessage (MessageType::INFO , "Saving $ count references to cache " );
247
- file_put_contents ($ cacheDir . "/references " , serialize ($ references ));
248
- }
249
190
}
0 commit comments