whitfin / cachex

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

Remove fallbacks from a cache state #371

Closed whitfin closed 2 months ago

whitfin commented 2 months ago

Now that we have Cachex.fetch/4 there's really no point in :fallback on a cache state. Let's remove it!

whitfin commented 2 months ago

This is perhaps more involved, because it includes removal of :state inside fallbacks. I don't think Cachex should keep this, but it might be awkward for people going forwards.

My guess is that most of these "states" are just PIDs or names to other processes, so names can be used instead of states here. Either way, copying the cache state on every call does have a price so complex structures in the cache state definitely does have overhead. Rather than manage this, I'd rather offload to the user to handle as they see best.

All this being said, if there's a demand I'm not against putting something back in for this. Unfortunately I don't have the data here to make an informed decision, so I'd rather remove it and add it back instead of potentially maintain something unused.