statamic / ideas

💡Discussions on ideas and feature requests for Statamic
https://statamic.dev
31 stars 1 forks source link

Can we replace the ArrayCollection with Enumerable for ProvidesSearchables interface. #1051

Closed videni closed 1 year ago

videni commented 1 year ago

Because I got millions of resources, updating search index by command statatic:index:update would run out of memory, can we replace the ArrayCollection below with Enumerable? so make it possible to use generator.

<?php

namespace Statamic\Search;

use Illuminate\Support\ArrayCollection;

interface ProvidesSearchables
{
    public static function handle(): string;

    public static function referencePrefix(): string;

    public function setKeys(array $keys): self;

   // here,   is it better to use  Illuminate\Support\Enumerable?
    public function provide(): ArrayCollection;

    public function contains($searchable): bool;

    public function find(array $keys): Enumerable;
}
jasonvarga commented 1 year ago

Sure, we'll review a PR if you'd like to make it.