Closed whitfin closed 1 month ago
I think a better approach here is removing Cachex.count/2
and switching it into an option for Cachex.size/2
.
By default Cachex.size/2
will return the total number of records, but you can pass expired: false
to disable inclusion of expired records (which defaults to true).
This lessens the surface area of the API, but you don't lose out on functionality. There is therefore also no reason to add anything to Cachex.inspect/2
(which already surfaces the count of expired records, so we have the trifecta now).
There are two ways to size your cache:
Cachex.count/2
which takes expiration into accountCachex.size/2
which doesn't take expiration into accountEven as the author, I totally forgot this and have been using
Cachex.size/2
for everything. I think we should:Cachex.count/2
intoCachex.size/2
Cachex.size/2
toCachex.inspect/2
Cachex.count/2
I think this makes a lot more sense, and is less likely to trip people up. That said, based on the amount of churn turned up in tests here, we might leave this alone...