Your use of the functions cache_set()
and cache_clear_all()
does not look right.
First let us look at cache_set()
. It stores some serialized data in some persistent cache bin.
Its arguments are:
- $cid - a string that identifies the stored data. The same string is stored in the
$cid
field in the database table named by the$bin
argument. - $data - the data to cache. This is stored in the
data
field identified by$bin
and$cid
, usually as a serialized object. - $bin - The name (a string) of the cache bin to use. This corresponds to a database table with that name. It should either be
'cache'
or start with the string'cache_'
. - $expire - when should the item expire. If set to CACHE_PERMANENT, the item can only be expired by calling
cache_clear_all()
.
You want to cache some parameters attached to some node. To do that, you may use:
$cid = 'mymodule_''mymodule:node_' . $nid;
$data = ...; // Set it to hold whatever object you want to cache.
$bin = 'cache';
cache_set($cid, $data, $bin, CACHE_PERMANENT);
Note that $bin
need to be set to the name of one of the bins (i.e. cache database tables) that are already defined.
Now, to clear out this particular item, you need to call cache_clear_all()
with the same $cid
and $bin
as was you to set the cache. The final parameter to cache_clear_all()
can indicate that $cid
is a wildcard (in your case, it is not). I.e.:
cache_clear_all($cid, $bin, FALSE);