Kirby 3 Plugin AutoID

This is the time Kirby needs to build the index. Done only once per page refresh.

$page->index()->count()
1110 pages in index to call core kirby $page->index()

Pages with AutoID and their cached Collection with modified()

// setup a semi-unique id for this group
$collectionID = "page('autoid')->index()";

// get cached collection, returns null if modified
$collection = modified($collectionID);

// if does not exist yet or was modified
if(!$collection) {
  $collection = modified($collectionID, page('autoid')->index());
  echo '=> Collection Cache: created or refreshed because modified.'.PHP_EOL;
} else {
  echo '=> Collection Cache: read.'.PHP_EOL;
}

foreach($collection as $p) {
  dump($p->url());
}
      
to check modified. Even if Kirbys Page Index is not created yet this time measurement stays the same. It depends only on AutoIDs cache.

=> Collection Cache: created or refreshed because modified.
to create/refresh/read collection from cache.
1110 pages in collection

If created or refreshed: check modified time + kirby index + write collection cache time
If cached: check modified time + read cache time = about 1/4 of index + almost 0

Usage autoid()

$page->content()->toArray();
Array
(
    [title] => Kirby 3 Plugin AutoID
    [text] => 953c64cc2db7346024d9f144390f2496
    [autoid] => abim0u8f
    [anystucture] => - 
  text: 9e279f7ef5929b8546142eaa4d0bccf7
- 
  text: a75f7f44ae9f1f59e87ab5bfbeabfd1b
    [anystructure] => 
)
$page->autoid();
Kirby\Cms\Field Object
(
    [autoid] => abim0u8f
)
autoid($page->autoid())->url();
https://kirby3-plugins.bnomei.com/autoid
autoid()->filterBy('autoid', $page->autoid())->first();
Array
(
    [pageid] => autoid
    [structure] => 
    [filename] => 
    [modified] => 1549478357
    [autoid] => abim0u8f
    [type] => page
)
$randomFileID = autoid()->filterBy('type', 'file')->shuffle()->first()['autoid'];
$randomFile = autoid($anyAutoID);
dump($randomFile->url());
      
to find random file. duration does not depend on size of $page->index() only on count of items indexed.
https://kirby3-plugins.bnomei.com/media/pages/autoid/test-5542a42b1808f10ca15a/test-086b0391cd5519134f62/-450850316-1534602726/flowers.jpg
$break = false;
foreach($page->index() as $pchi) {
  foreach($pchi->files() as $fi) {
    if($fi->id() == $randomFile->id()) {
      dump($randomFile->url());
      $break = true;
    }
    if($break) break;
  }
  if($break) break;
}
      
https://kirby3-plugins.bnomei.com/media/pages/autoid/test-5542a42b1808f10ca15a/test-086b0391cd5519134f62/-450850316-1534602726/flowers.jpg
to find same file with foreach loops. duration increases with size of $page->index().
In addition to walking the for loops you would have to add the time to create the index (see top of page).

Usage tinyurl()

$randomPage->autoid();
6z2vh42l
$randomPage->tinyurl();
test-5b1d7217dba63beaa7bc