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

Combine `count/2` and `size/2` to flatten API space #378

Closed whitfin closed 1 month ago

whitfin commented 1 month ago

This fixes #376.

Pretty much as described in the issue; flattens Cachex.count/2 into Cachex.size/2. The default behaviour of Cachex.size/2 is unchanged, but you can now provide expired: false to make it act like the previous Cachex.count/2.

The default for Cachex.size/2 remains the same for compatibility, but it's also far cheaper and generally (I think) more intuitive anyway.