-
-
Notifications
You must be signed in to change notification settings - Fork 972
Improve performance of the metadata system #1256
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -63,7 +63,10 @@ public function testCreateWithItemNotHit() | |
| $resultedResourceMetadata = $cachedResourceMetadataFactory->create(Dummy::class); | ||
|
|
||
| $this->assertInstanceOf(ResourceMetadata::class, $resultedResourceMetadata); | ||
| $this->assertEquals(new ResourceMetadata(null, 'Dummy.'), $resultedResourceMetadata); | ||
|
|
||
| $expectedResult = new ResourceMetadata(null, 'Dummy.'); | ||
| $this->assertEquals($expectedResult, $resultedResourceMetadata); | ||
| $this->assertEquals($expectedResult, $cachedResourceMetadataFactory->create(Dummy::class), 'Trigger the local cache'); | ||
| } | ||
|
|
||
| public function testCreateWithGetCacheItemThrowsCacheException() | ||
|
|
@@ -81,11 +84,14 @@ public function testCreateWithGetCacheItemThrowsCacheException() | |
| $resultedResourceMetadata = $cachedResourceMetadataFactory->create(Dummy::class); | ||
|
|
||
| $this->assertInstanceOf(ResourceMetadata::class, $resultedResourceMetadata); | ||
| $this->assertEquals(new ResourceMetadata(null, 'Dummy.'), $resultedResourceMetadata); | ||
|
|
||
| $expectedResult = new ResourceMetadata(null, 'Dummy.'); | ||
| $this->assertEquals($expectedResult, $resultedResourceMetadata); | ||
| $this->assertEquals($expectedResult, $cachedResourceMetadataFactory->create(Dummy::class), 'Trigger the local cache'); | ||
| } | ||
|
|
||
| private function generateCacheKey(string $resourceClass = Dummy::class) | ||
| { | ||
| return CachedResourceMetadataFactory::CACHE_KEY_PREFIX.md5(serialize([$resourceClass])); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @teohhanhui you had a good reason to serialize here? (I think it comes from you) Do we really need the
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is necessary because the key must not exceed 64 chars (PSR-6). A long class name may exceed this. |
||
| return CachedResourceMetadataFactory::CACHE_KEY_PREFIX.md5($resourceClass); | ||
| } | ||
| } | ||
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.
$memoryCacheis not a very descriptive name... 😞Perhaps
$localCacheand$localCacheKey. Descriptive is better.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.
@teohhanhui however it's exactly what it is, a memory cache.
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.
APCu is also a (shared) memory cache. This is the local memory cache. 😆
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.
The word memory is just redundant and meaningless since all the variables are in memory anyway...
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.
How about
loaded?