feat(cache): add iterate method to list files from cache#57911
feat(cache): add iterate method to list files from cache#57911
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.
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.
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.
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.
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)