Skip to content

Commit ed41df0

Browse files
authored
Remove caching for now (#118)
1 parent 867196b commit ed41df0

File tree

1 file changed

+0
-59
lines changed

1 file changed

+0
-59
lines changed

src/LanguageServer.php

Lines changed: 0 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,6 @@ public function initialize(int $processId, ClientCapabilities $capabilities, str
103103

104104
// start building project index
105105
if ($rootPath !== null) {
106-
$this->restoreCache();
107106
$this->indexProject();
108107
}
109108

@@ -135,9 +134,6 @@ public function initialize(int $processId, ClientCapabilities $capabilities, str
135134
*/
136135
public function shutdown()
137136
{
138-
if ($this->rootPath !== null) {
139-
$this->saveCache();
140-
}
141137
}
142138

143139
/**
@@ -181,69 +177,14 @@ private function indexProject()
181177
}
182178
}
183179

184-
if ($fileNum % 1000 === 0) {
185-
$this->saveCache();
186-
}
187-
188180
Loop\setTimeout($processFile, 0);
189181
} else {
190182
$duration = (int)(microtime(true) - $startTime);
191183
$mem = (int)(memory_get_usage(true) / (1024 * 1024));
192184
$this->client->window->logMessage(MessageType::INFO, "All PHP files parsed in $duration seconds. $mem MiB allocated.");
193-
$this->saveCache();
194185
}
195186
};
196187

197188
Loop\setTimeout($processFile, 0);
198189
}
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-
}
249190
}

0 commit comments

Comments
 (0)