Skip to main content
added 355 characters in body
Source Link
Free Radical
  • 15.1k
  • 9
  • 48
  • 83

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);

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.

Its arguments are:

  • $cid - a string that identifies the stored data.
  • $data - the data to cache.
  • $bin - The name (a string) of the cache bin to use.
  • $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_' . $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 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);

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: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);
added 2 characters in body
Source Link
Free Radical
  • 15.1k
  • 9
  • 48
  • 83

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.

Its arguments are:

  • $cid - a string that identifies the stored data.
  • $data - the data to cache.
  • $bin - The name (a string) of the cache bin to use.
  • $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_' . $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 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);

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.

Its arguments are:

  • $cid - a string that identifies the stored data.
  • $data - the data to cache.
  • $bin - The name (a string) of the cache bin to use.
  • $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_' . $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 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);

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.

Its arguments are:

  • $cid - a string that identifies the stored data.
  • $data - the data to cache.
  • $bin - The name (a string) of the cache bin to use.
  • $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_' . $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 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);
added 703 characters in body
Source Link
Free Radical
  • 15.1k
  • 9
  • 48
  • 83

For one thing,Your use of the postedfunctions hook_croncache_set() looks wrongand cache_clear_all() does not look right. You need the keyword

First let us look at functioncache_set(). It stores some serialized data in front of the name, and "hook" should not be a part of the namesome persistent cache. Use this as a stating point

Its arguments are:

  • $cid - a string that identifies the stored data.
  • $data - the data to cache.
  • $bin - The name (a string) of the cache bin to use.
  • $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 *= Implements'mymodule_' hook_cron(). $nid;
$data *= ...; /
function/ MYMODULE_cronSet {it to hold whatever object you want to cache.
$bin = cache_clear_all'cache';
cache_set('*'$cid, MY_CACHE$data, TRUE);
 $bin, take_params(CACHE_PERMANENT);
}

But replace "MYMODULE" withNote that $bin need to be set to the machinenamename of one of the custom module you've placedbins that are already defined.

Now, to clear out this particular item, you need to call cache_clear_all() with the hook insame $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);

For one thing, the posted hook_cron looks wrong. You need the keyword function in front of the name, and "hook" should not be a part of the name. Use this as a stating point:

/**
 * Implements hook_cron().
 */
function MYMODULE_cron {
  cache_clear_all('*', MY_CACHE, TRUE);
  take_params();
}

But replace "MYMODULE" with the machinename of the custom module you've placed the hook in.

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.

Its arguments are:

  • $cid - a string that identifies the stored data.
  • $data - the data to cache.
  • $bin - The name (a string) of the cache bin to use.
  • $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_' . $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 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);
Source Link
Free Radical
  • 15.1k
  • 9
  • 48
  • 83
Loading