-
-
Save jasonvarga/020042f9b1efe5cb9ec152d8c8cfb3e6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$files = Storage::files(); // one api call | |
foreach ($files as $file) { | |
$arr = [ | |
'size' => Storage::size($file), // one api call | |
'timestamp' => Storage::lastModified($file), // one api call | |
]; | |
} | |
// Without caching: | |
// ------ | |
// 1 api call for listing | |
// 2 api call for each file | |
// ------ | |
// 10 files in the directory, 21 api calls | |
// 50 files, 101 api calls | |
// 100 files, 201 api calls, etc | |
// With memory request caching: ('cache' => true) | |
// ------ | |
// 1 api call for listing, which caches all the meta data | |
// 0 api call for each file, since they were cached | |
// ------ | |
// 10 files, 1 api call | |
// 50 files, 1 api call | |
// 100 files, 1 api call, etc | |
// When using a cache store, you will have 1 API call for the listing, | |
// then no API calls for future requests while the flysystem data remains in the cache. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment