Recently a friend of mine has an issue with his drupal 7.16 site. What happened what that his cache tables kept on growing, up untill a point that the DB exceeded the max size allowed by his hosting provider.
The DB itself, with empty cache is about 40 MB. The max size of the DB is 100 MB, which means the cache made up more than 60 MB!
I did a bit of digging, an what I found was that the entries in the cache tables have a column called expire. The column has the description "A Unix timestamp indicating when the cache entry should expire, or 0 for never."
However, all the entries were listed as 0, which means they would never get deleted.
I solved this problem by editing the cache.inc file of drupal (yes, I know you are not supposed to do this, but yeah).
I changed the function cache_set to the following.
function cache_set($cid, $data, $bin = 'cache', $expire = CACHE_PERMANENT) {
$expire = time() + 3600; //this is the line of code I added
return _cache_get_object($bin)->set($cid, $data, $expire);
}
Basically this forcefully overwrite the expire variable which has been passed. Now the entries in the expire column do get a value, and the cache tables do get cleaned up by cron jobs.
Is this a know Drupal issue, and is there some fix for it?
Thijs
Comments
Very very LARGES caches
Hi!
I have the same problem whit a D7.22 (upgraded from a D6). I have tryed a few things, using some cache modules, but nothing worked.
I have found as well that the entries in the cache tables have a column called expire. The column has the description "A Unix timestamp indicating when the cache entry should expire, or 0 for never." and that all the entries were listed as 0!! Which means they would never get deleted.
The biggest cache was cache_metatag, running over 130M!!
I will try your fix and ask the question again :
Is this a know Drupal issue, and is there some fix for it?
Can this be an issue of the upgrade path from D6 to D7?
Thx.