Using (D)ETS

In the previous section, we implemented the ElixirDrip text search functionality by using Task.async_stream/5 to search several text files at the same time. The text search function lived on the ElixirDrip.Storage.Search module and its last iteration could be used like this:

iex> alias ElixirDrip.Storage.Searchiex> media_ids = ["25", "8", "6", "7"]iex> search_expression = "media"iex> Search.safe_task_stream_search_for(media_ids, search_expression)%{  "6" => [{1, "Content of media 6."}],  "7" => [{1, "Content of media 7."}],  "8" => [{1, "Content of media 8."}]}

It returned a map with entries for every searched file whose search ended on the allotted time. For each media id, it yields a list of two-element tuples, where the first ...

Get Mastering Elixir now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.