function memcache_variable_set in Memcache API and Integration 6
Re-implementation of variable_set() that writes through instead of clearing.
2 calls to memcache_variable_set()
- cache_clear_all in ./
memcache.inc - Expire data from the cache. If called without arguments, expirable entries will be cleared from the cache_page and cache_block tables.
- memcache_wildcards in ./
memcache.inc - Utilize multiget to retrieve all possible wildcard matches, storing statically so multiple cache requests for the same item on the same page load doesn't add overhead.
File
- ./
memcache.inc, line 472
Code
function memcache_variable_set($name, $value) {
global $conf;
// If the value appears unchanged, do nothing.
if (isset($conf[$name]) && $conf[$name] === $value) {
return;
}
$serialized_value = serialize($value);
db_query("UPDATE {variable} SET value = '%s' WHERE name = '%s'", $serialized_value, $name);
if (!db_affected_rows()) {
@db_query("INSERT INTO {variable} (name, value) VALUES ('%s', '%s')", $name, $serialized_value);
}
// If the variables are cached, get a fresh copy, update with the new value
// and set it again.
if ($cached = cache_get('variables', 'cache')) {
$variables = $cached->data;
$variables[$name] = $value;
cache_set('variables', $variables);
}
// If the variables aren't cached, there's no need to do anything.
$conf[$name] = $value;
}