mecha-cms / mecha

Minimalist content management system.

Home Page:https://mecha-cms.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

TODO: Rename `Cache::expire()` to `Cache::stale()`

taufik-nurrohman opened this issue · comments

“expire” vs. “stale”

Verb Adjective
Screenshot_2020-05-31-12-40-10-656_com dictionary Screenshot_2020-05-31-12-39-47-804_com dictionary

Consider this. Which one is more logic to you?

if (Cache::expire('.\path\to\file.txt', '1 day')) {
    // Do something if cache has been expired…
    // or, to expire a cache reference? 🤨
}
if (Cache::stale('.\path\to\file.txt', '1 day')) {
    // Do something if cache has been expired…
    // is like, if cache is stale (already expired) then do something 😊
}

Cache::expire() is more appropriate to be used as a task “to do something”. In this case, “to force expire a cache reference that has not been expired”. The case will be different if we use Cache::expired() instead, but I’m trying to use the shortest adjective as possible. Just like how I have decided to design get, let and set in version 2.2.0.

Also, removing a cache is considered as an action to force expire a cache reference too. We already have Cache::let() by the way:

// Force cache reference to be expired
Cache::let('.\path\to\file.txt');