rails / solid_cache

A database-backed ActiveSupport::Cache::Store
MIT License
890 stars 63 forks source link

Replace expiry counter with random chance #132

Closed djmb closed 10 months ago

djmb commented 10 months ago

If the lifespan of a process is smaller than an expiry cycle then it may not trigger the expiry process often enough. We mitigate this a little bit by pre-filling the counter with a random number, but that means that on average a process still needs to survive for half an expiry cycle.

Instead lets trigger expiry randomly, but keep the same overall frequency. This will always give us an expiry rate proportional to the number of writes whatever the process length.

Fixes #91