Commit 74c35a0c authored by robertDouglass's avatar robertDouglass
Browse files

Adding taxonomy.patch. Apply this patch to memcache taxonomy vocabularies, trees and terms.

parent 28806090
......@@ -5,6 +5,7 @@ function memcache_taxonomy($op, $type, $object=NULL) {
return;
}
$object = (array)$object;
switch ($type) {
case 'term':
$key = $object['tid'];
......@@ -21,7 +22,7 @@ function memcache_taxonomy($op, $type, $object=NULL) {
switch ($op) {
case 'delete':
case 'update':
dmemcache_delete($key, 'taxonomy_get_tree', TRUE);
dmemcache_flush($key, 'taxonomy_get_tree');
dmemcache_delete($key, $type);
}
......
Index: modules/taxonomy/taxonomy.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/taxonomy/taxonomy.module,v
retrieving revision 1.330
diff -u -r1.330 taxonomy.module
--- modules/taxonomy/taxonomy.module 11 Jan 2007 03:29:15 -0000 1.330
+++ modules/taxonomy/taxonomy.module 12 Jan 2007 22:16:29 -0000
@@ -967,6 +967,13 @@
function taxonomy_get_tree($vid, $parent = 0, $depth = -1, $max_depth = NULL) {
static $children, $parents, $terms;
+ if ((0 === $parent) && (-1 === $depth) && $mc_tree = dmemcache_get($vid, 'taxonomy_get_tree')) {
+ return $mc_tree;
+ }
+ else {
+ $cache_tree = TRUE;
+ }
+
$depth++;
// We cache trees, so it's not CPU-intensive to call get_tree() on a term
@@ -1000,6 +1007,10 @@
}
}
+ if ($cache_tree) {
+ dmemcache_set($vid, $tree, 0, 'taxonomy_get_tree');
+ }
+
return $tree ? $tree : array();
}
@@ -1121,14 +1132,21 @@
function taxonomy_get_vocabulary($vid) {
static $vocabularies = array();
+
if (!array_key_exists($vid, $vocabularies)) {
- $result = db_query('SELECT v.*, n.type FROM {vocabulary} v LEFT JOIN {vocabulary_node_types} n ON v.vid = n.vid WHERE v.vid = %d ORDER BY v.weight, v.name', $vid);
- $node_types = array();
- while ($voc = db_fetch_object($result)) {
- $node_types[] = $voc->type;
- unset($voc->type);
- $voc->nodes = $node_types;
- $vocabularies[$vid] = $voc;
+ if ($vocabulary = dmemcache_get($vid, 'vocabulary')) {
+ $vocabularies[$vid] = $vocabulary;
+ }
+ else {
+ $result = db_query('SELECT v.*, n.type FROM {vocabulary} v LEFT JOIN {vocabulary_node_types} n ON v.vid = n.vid WHERE v.vid = %d ORDER BY v.weight, v.name', $vid);
+ $node_types = array();
+ while ($voc = db_fetch_object($result)) {
+ $node_types[] = $voc->type;
+ unset($voc->type);
+ $voc->nodes = $node_types;
+ $vocabularies[$vid] = $voc;
+ dmemcache_set($vid, $voc, 0, 'vocabulary');
+ }
}
}
@@ -1148,7 +1166,13 @@
static $terms = array();
if (!isset($terms[$tid])) {
- $terms[$tid] = db_fetch_object(db_query('SELECT * FROM {term_data} WHERE tid = %d', $tid));
+ if ($term = dmemcache_get($tid, 'term')) {
+ $terms[$tid] = $term;
+ }
+ else {
+ $terms[$tid] = db_fetch_object(db_query('SELECT * FROM {term_data} WHERE tid = %d', $tid));
+ dmemcache_set($tid, $terms[$tid], 0, 'term');
+ }
}
return $terms[$tid];
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment