Our site with Drupal 6.26 (published 2012-05-02) kept crashing because it filled its
`cache_menu` table too quickly.
This is a drop-in replacement for
includes/cache.inc that makes Drupal use a filesystem-based cache instead of the database.
- Download the file (http://trac.rezo.net/trac/rezo/brow...)
- Rename the old
includes/cache.classic.inc, in case you want to go back.
- Install this file as
- By default, we use the
sys_get_temp_dir()command to learn where to store the cache files. If you prefer to see what happens, create a
tmp/directory (with proper write permissions for
www-dataand a security
.htaccessfile); the code will use this directory if it exists.
This has not been tested yet on any other version than Drupal 6.26. If it works for you, please comment in the forum below.
How it works
When Drupal tries to cache some data it uses
cache_set($cid, $data, $table, $expire, $headers)
… our code computes a 4-hexdigits hash key from
(cid, table), and stores the values
(data, headers) in the file named
When Drupal requests this value from the cache, we load the values from the same file, check that the
table match the request, that the cache has not
expired, and then return the value.
There will be collisions in this small space (
16^4= 65,536 files “only”). But that’s a deliberate feature, because it allows us to avoid using a costly garbage collector .
P.S. Something better probably exists somewhere. I just couldn’t find it; if this is useful for you, or if you have suggestions, please comment below.