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

Remove :stats and :limit from the list of cache options #374

Closed whitfin closed 1 month ago

whitfin commented 1 month ago

This fixes #368.

There's a lot in here, but the gist is that :stats and :limit have been completely removed in favour of simply providing the hooks directly. This is a much smaller implementation, and is easier to understand (because we're guiding everyone to hooks).

This also introduces a new cache action via Cachex.prune/3 which can be used to manually prune a cache to a size. This is used by the hooks under the hood.

Hook records have also had :state => :args to better show that they can have modified state, more inline with GenServer.