WordPress.org

Ready to get started?Download WordPress

Forums

Using cache functions with plugins or custom functions (2 posts)

  1. Eric Martin
    Member
    Posted 5 years ago #

    I am writing some custom functions in my themes' functions.php file.

    In particular, I am looking to customize my archive display, so I intend to create my own query to get the results back directly.

    In looking at wp_get_archives in general-template.php, I see the following cache logic:

    if ( !isset( $cache[ $key ] ) ) {
    	$arcresults = $wpdb->get_results($query);
    	$cache[ $key ] = $arcresults;
    	wp_cache_add( 'wp_get_archives', $cache, 'general' );
    } else {
    	$arcresults = $cache[ $key ];
    }

    So, I'm curious...for my custom function(s) (or for anyone doing custom queries for plugins), should we/I be using similar logic to store/retrieve results from cache?

  2. Eric Martin
    Member
    Posted 5 years ago #

    Anyone?

Topic Closed

This topic has been closed to new replies.

About this Topic