function kjgrc_cache($type) { global $wpdb, $kjgrc_cache, $kjgrc_we_are_a_widget, $kjgrc_widget_args; $use_cache = FALSE; if (kjgrc_use_cache()) { $use_cache = TRUE; } if ($use_cache == FALSE) { // kjgrc_log("return cache without caching"); $kjgrc_cache[comments] = kjgrc_prepare_cache(kjgrc_create_recent_comments()); $kjgrc_cache[trackbacks] = kjgrc_prepare_cache(kjgrc_create_recent_trackbacks()); return $kjgrc_cache[$type]; } if ($kjgrc_cache == NULL) { // kjgrc_log("return cache WITH caching"); $kjgrc_cache = get_option('kjgrc_cache'); if ($kjgrc_cache == NULL) { // kjgrc_log("write new cache"); $kjgrc_cache[comments] = base64_encode(kjgrc_create_recent_comments()); $kjgrc_cache[trackbacks] = base64_encode(kjgrc_create_recent_trackbacks()); if ($kjgrc_we_are_a_widget == TRUE) { extract($kjgrc_widget_args); if ($before_title == '%BEG_OF_TITLE%') { // Don't update cache now. } else { update_option('kjgrc_cache', $kjgrc_cache); } } else { update_option('kjgrc_cache', $kjgrc_cache); } } $kjgrc_cache[comments] = kjgrc_prepare_cache(base64_decode($kjgrc_cache[comments])); $kjgrc_cache[trackbacks] = kjgrc_prepare_cache(base64_decode($kjgrc_cache[trackbacks])); } // search and replace up to date information return $kjgrc_cache[$type]; }
function kjgrc_cache($type) { global $wpdb, $kjgrc_cache; $use_cache = FALSE; if (kjgrc_use_cache()) { $use_cache = TRUE; } if ($use_cache == FALSE) { // kjgrc_log("return cache without caching"); $kjgrc_cache[comments] = kjgrc_prepare_cache(kjgrc_create_recent_comments()); $kjgrc_cache[trackbacks] = kjgrc_prepare_cache(kjgrc_create_recent_trackbacks()); return $kjgrc_cache[$type]; } if ($kjgrc_cache == NULL) { // kjgrc_log("return cache WITH caching"); $kjgrc_cache = get_option('kjgrc_cache'); if ($kjgrc_cache == NULL) { // kjgrc_log("write new cache"); $kjgrc_cache[comments] = base64_encode(kjgrc_create_recent_comments()); $kjgrc_cache[trackbacks] = base64_encode(kjgrc_create_recent_trackbacks()); update_option('kjgrc_cache', $kjgrc_cache); } $kjgrc_cache[comments] = kjgrc_prepare_cache(base64_decode($kjgrc_cache[comments])); $kjgrc_cache[trackbacks] = kjgrc_prepare_cache(base64_decode($kjgrc_cache[trackbacks])); } // search and replace up to date information return $kjgrc_cache[$type]; }