Instantly share code, notes, and snippets.

Embed
What would you like to do?
<?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