Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 PST on 31 March 2024, to get $100 off your ticket.
filecache_cron has
if ($cache->expire == CACHE_TEMPORARY ||
$cache->expire < REQUEST_TIME) {
@unlink($filename);
}
But cache_set's documentation states
* @param $expire
* (optional) One of the following values:
* - CACHE_PERMANENT: Indicates that the item should never be removed unless
* explicitly told to using cache_clear_all() with a cache ID.
* - CACHE_TEMPORARY: Indicates that the item should be removed at the next
* general cache wipe.
* - A Unix timestamp: Indicates that the item should be kept at least until
* the given time, after which it behaves like CACHE_TEMPORARY.
*
And I believe that a cron run should not do a general cache wipe (only a cache_clear_all should), but only clear the files that have expired.
Comment | File | Size | Author |
---|---|---|---|
#5 | filecache-not_always_remove_temporary_on_cron-2530522-5.patch | 594 bytes | Sneakyvv |
Comments
Comment #1
Sneakyvv CreditAttribution: Sneakyvv commentedPatch attached, which takes cache_lifetime into account on cron, instead of deleting all CACHE_TEMPORARY files.
Comment #2
Sneakyvv CreditAttribution: Sneakyvv commentedPatch applies to latest dev as well
Comment #3
Sneakyvv CreditAttribution: Sneakyvv commentedTriggered test bot
Comment #4
Anonymous (not verified) CreditAttribution: Anonymous as a volunteer commentedI confirm this problem, & also that this patch applies cleanly to the latest dev & solves the problem. RTBC.
That being said, I wonder why this cache backend is concerning itself with cache expiration anyway. Wouldn't it make more sense to leave cache expiration to a module like Cache Expiration & confine this module to cache storage? Cache expiration is already a hard problem, so why make it more complicated by having multiple modules influencing it?
What would be harmed by ripping out filecache_cron() entirely?
Comment #5
Sneakyvv CreditAttribution: Sneakyvv commented@rhclayto: Cache expiration is a module which allows you to expire the cache in a better fashion, i.e. not via a global minimum lifetime setting. So now, file cache works without an extra module. Of course it could depend on for example cache expiration...
Btw, I'm using file cache in combination with cache_lifetime_options, which allows me to cache pages up to a year and expire them via cache expiration.
PS: I've noticed my previous patch had one small issue. The '+=' would cause the cache to expire one second too early, since CACHE_TEMPORARY is -1.
Comment #7
ogi CreditAttribution: ogi commentedThank you for providing patch. I decided to make a release for this one.