Skip to content

Commit

Permalink
🐛 boost for file was resolving parent
Browse files Browse the repository at this point in the history
Signed-off-by: bnomei <b@bnomei.com>
  • Loading branch information
bnomei committed Oct 20, 2023
1 parent 9b39602 commit 25843b1
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 9 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "bnomei/kirby3-boost",
"type": "kirby-plugin",
"version": "2.4.0",
"version": "2.4.1",
"description": "Boost the speed of Kirby by having content files of files/pages/users cached, with fast lookup based on uuid.",
"license": "MIT",
"authors": [
Expand Down
2 changes: 1 addition & 1 deletion composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion index.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ function boost($id)
// since that is faster than letting kirby core do it
// FileUuuid::findByCache() would resolve so we do it manually
if ($uuid = FileUuid::for($schema . '://' . $id) ) {
$value = $uuid->value();
// $value = $uuid->value(); // would resolve parent
$value = Uuids::cache()->get($uuid->key());
if (!$value) {
return null;
}
Expand Down
12 changes: 10 additions & 2 deletions tests/BoostTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,15 +158,23 @@ public function testNonTranslatable()
public function testBoostCanLoadFile() {
$fileUuid = 'file://hp4IB3c6UxKODRyK';
$time = microtime(true);
$file = boost($fileUuid);
$c = 10000;
while ($c > 0) {
$file = boost($fileUuid);
$c--;
}
echo 'boost(): ' . (microtime(true) - $time) . PHP_EOL;
$this->assertEquals($file->uuid()->toString(), $fileUuid);
}

public function testKirbyCanLoadFile() {
$fileUuid = 'file://hp4IB3c6UxKODRyK';
$time = microtime(true);
$file = site()->file($fileUuid);
$c = 10000;
while ($c > 0) {
$file = site()->file($fileUuid);
$c--;
}
echo 'site()->file(): ' . (microtime(true) - $time) . PHP_EOL;
$this->assertEquals($file->uuid()->toString(), $fileUuid);
}
Expand Down
8 changes: 4 additions & 4 deletions vendor/composer/installed.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php return array(
'root' => array(
'name' => 'bnomei/kirby3-boost',
'pretty_version' => '2.4.0',
'version' => '2.4.0.0',
'pretty_version' => '2.4.1',
'version' => '2.4.1.0',
'reference' => NULL,
'type' => 'kirby-plugin',
'install_path' => __DIR__ . '/../../',
Expand All @@ -11,8 +11,8 @@
),
'versions' => array(
'bnomei/kirby3-boost' => array(
'pretty_version' => '2.4.0',
'version' => '2.4.0.0',
'pretty_version' => '2.4.1',
'version' => '2.4.1.0',
'reference' => NULL,
'type' => 'kirby-plugin',
'install_path' => __DIR__ . '/../../',
Expand Down

0 comments on commit 25843b1

Please sign in to comment.