-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
feat(cache): add iterate method to list files from cache #57911
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
base: master
Are you sure you want to change the base?
Conversation
21d7b9f to
1282816
Compare
Signed-off-by: Benjamin Gaussorgues <benjamin.gaussorgues@nextcloud.com>
1282816 to
d7e81e7
Compare
| * @return iterable<ICacheEntry> | ||
| * @since 34.0.0 | ||
| */ | ||
| public function iterateFolderContentsById(int $fileId, bool $includeMetadata = false, bool $sortByName = false): iterable; |
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.
Given that getFolderContentsById() does not support those parameters, are $includeMetadata and $sortByName really useful?
Also, you touched a comment suggesting that having a mimetype parameter would be nice.
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.
These parameters are optimisations for the underlying query. If we don't use metadata, better avoid the join. If we don't need sorted elements, better leave default order.
From what I've found, the mimetype filter is not really used. That's why I didn't implemented it, but I can :)
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.
Maybe we should think about another kind of API… Something like:
// Similar to getFolderContentsById()
$cache->iterateById($folderId)->withMetadata()->sortBy(ICache::SORT_NAME)->exec();
// Unsorted list of ID
$cache->iterateById($folderId)->asType(ICache::RESULT_ID)->exec();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.
Another though, adding those kinds of arguments/filters sounds more like a search than a listing. So if those are actually useful, maybe we could name the new method something like searchFolderContentsById.
Summary
Add an iterator to list files from a directory
Reduce memory usage on large directory listing (≈ 800 files here):

Also helps to remove large number of files with Primary object store
Checklist
3. to review, feature component)stable32)