whitfin / cachex

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

Avoid running Janitor services until expirations are created #367

Closed whitfin closed 2 months ago

whitfin commented 2 months ago

The Janitor is one of the heavier services, and it's the only Cachex feature enabled by default.

It was enabled by default because it was misleading for users when it wasn't. This means that people who do not use expirations will have a pointless transaction lock running every few seconds.

We should see if we can do something to lazily initialize the Janitor. The process can be running, but the loop should not be. This is specifically intended to lower overhead, so we can only implement this with a very minimal approach.