Skip to Main Content
Mastering Elixir
book

Mastering Elixir

by André Albuquerque, Daniel Caixinha
July 2018
Intermediate to advanced content levelIntermediate to advanced
574 pages
14h 7m
English
Packt Publishing
Content preview from Mastering Elixir

Implementing a CacheWorker with GenServer

We will now implement a CacheWorker process on ElixirDrip, which we'll use to keep the most recent media in memory. By using this cache mechanism, we hope to reduce the time it takes for a file to be downloaded and also avoid having to run the full download pipeline for every download handled by ElixirDrip.

Our CacheWorker will keep some content in memory for a while, associated with a specific cache key. In our case, the cache key will be the id of the media. Since we don't want to spawn more than one cache process for the same media, we will also use the media id on the process name. This way, if someone tries to cache media that already lives in the cache, it will be informed that a process with ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Testing Elixir

Testing Elixir

Andrea Leopardi, Jeffrey Matthias

Publisher Resources

ISBN: 9781788472678Supplemental Content