Index: tagadelic.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/tagadelic/tagadelic.module,v
retrieving revision 1.36.2.11
diff -u -r1.36.2.11 tagadelic.module
--- tagadelic.module	14 Aug 2008 19:05:49 -0000	1.36.2.11
+++ tagadelic.module	18 Mar 2009 16:23:46 -0000
@@ -204,13 +204,30 @@
  * @return An <em>unordered</em> array with tags-objects, containing the attribute $tag->weight;
  */
 function tagadelic_get_weighted_tags($vids, $steps = 6, $size = 60) {
-  //CACHING! PLease! Send! in! your! patches! :)
-  if (!is_array($vids) || count($vids) == 0) {
-    return array();
+  // build the options so we can cache multiple versions
+  $options = implode($vids) .'_'. $steps .'_'. $size;
+  
+  // Check if the cache exists
+  $cache_name = 'tagadelic_cache_'. $options;
+  $cache = cache_get($cache_name);
+  
+  // make sure cache has data
+  if (isset($cache->data)) {
+    $tags = unserialize($cache->data);
   }
-  $result = db_query_range('SELECT COUNT(*) AS count, d.tid, d.name, d.vid FROM {term_data} d INNER JOIN {term_node} n ON d.tid = n.tid WHERE d.vid IN ('. substr(str_repeat('%d,', count($vids)), 0, -1) .') GROUP BY d.tid, d.name, d.vid ORDER BY count DESC', $vids, 0, $size);
+  else {
 
-  return tagadelic_build_weighted_tags($result, $steps);
+    if (!is_array($vids) || count($vids) == 0) {
+      return array();
+    }
+    $result = db_query_range('SELECT COUNT(*) AS count, d.tid, d.name, d.vid FROM {term_data} d INNER JOIN {term_node} n ON d.tid = n.tid WHERE d.vid IN ('. substr(str_repeat('%d,', count($vids)), 0, -1) .') GROUP BY d.tid, d.name, d.vid ORDER BY count DESC', $vids, 0, $size);
+
+    $tags = tagadelic_build_weighted_tags($result, $steps);
+    
+    cache_set($cache_name, 'cache', serialize($tags), CACHE_TEMPORARY);
+  }
+    
+  return $tags;
 }
 
 /**

