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 Cachex.Policy in favour of hooks #368

Closed whitfin closed 1 month ago

whitfin commented 1 month ago

There is no real point of policies and limits in the current implementation of Cachex.

Each existing limit simply spawns hooks to handle the management of a cache, so we should remove the modules for policies and simply document adding of the hooks instead. This is quite a big change, but it should make a lot more sense on completion.

whitfin commented 1 month ago

The thinking here is simply documenting the LRW policy as a LRW cleanup hook (not sure of the naming yet). The LRU policy will simply be a hook which updates the modification time, and the documentation will state how you can use that alongside LRW to produce LRU.

whitfin commented 1 month ago

This will also include various changes with hooks in general, such as removing :stats in favour of explicit addition.