-
Notifications
You must be signed in to change notification settings - Fork 185
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cache source packages when reference/revision is available #367
base: master
Are you sure you want to change the base?
Conversation
Codecov Report
@@ Coverage Diff @@
## master #367 +/- ##
============================================
+ Coverage 84.33% 86.95% +2.61%
- Complexity 834 835 +1
============================================
Files 59 59
Lines 1724 1732 +8
============================================
+ Hits 1454 1506 +52
+ Misses 270 226 -44
|
Regarding testing for this change, I'm still wrapping my head around the code. I think it can be accomplished by including a composer.json and composer.lock within fixtures to mock a faux install. I'm going to look into this further. |
src/Indexer.php
Outdated
$packageVersion = ltrim($package->version, 'v'); | ||
// If package is anchored to a version | ||
if ($package->name === $packageName && strpos($packageVersion, 'dev') === false) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
package name is checked in both conditions
src/Indexer.php
Outdated
if ($package->name === $packageName && strpos($packageVersion, 'dev') === false) { | ||
$packageKey = $packageName . ':' . $packageVersion; | ||
$cacheKey = self::CACHE_VERSION . ':' . $packageKey; | ||
// Check cache | ||
$index = yield $this->cache->get($cacheKey); | ||
break; | ||
|
||
// If package is checked out | ||
} elseif ($package->name === $packageName && isset($package->source->reference)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
space between else if
LGTM overall. |
I've made changes based off your feedback, and modified tests for the two current package caching strategies. I think this is ready for another review. |
Could you do the tests as a unit test for the Indexer? |
I'd be willing to give it a shot. |
Any updates on this? |
Fixes #366
For projects that use specific revisions for packages (e.g. if a bug fix has not made it to a tagged release yet), the PHP language server would reparse the package's files every time the server started, even if the package had not changed. This change introduces caching support for packages that are checked out from source, by using the revision as part of the cache key.