Index: tagadelic.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/tagadelic/tagadelic.module,v retrieving revision 1.36.2.3 diff -u -p -r1.36.2.3 tagadelic.module --- tagadelic.module 13 Mar 2007 09:58:31 -0000 1.36.2.3 +++ tagadelic.module 31 Aug 2007 15:53:02 -0000 @@ -208,13 +208,32 @@ function tagadelic_tags_lists($node) { * @return An unordered 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(); - } - $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); + // CACHING! PLease! Send! in! your! patches! :) + + // 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( $cache->data) { + $tags = unserialize($cache->data); + } + else { + + 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); - return tagadelic_build_weighted_tags($result, $steps); + cache_set($cache_name, 'cache', serialize($tags)); + } + + return $tags; } /**