whitfin / cachex

A powerful caching library for Elixir with support for transactions, fallbacks and expirations
https://hexdocs.pm/cachex/
MIT License
1.6k stars 103 forks source link

Add a new :wait option to control Cachex.warm/2 #342

Closed whitfin closed 7 months ago

whitfin commented 7 months ago

This fixes #336.

This PR adds a new option :warm to the Cachex.warm/2 command which allows the user to specify whether they want to wait for all warmers to complete, or spawn the warming asynchronously.

This also allows us to re-use Cachex.warm/2 in the cache startup sequence, instead of re-implementing warming details there. The implementation now uses Task, which I'm not totally sure about, but I think it's better than running synchronous warmers one by one.