Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save spacedmonkey/763005309cdb1c852ff57e5ccb71a57b to your computer and use it in GitHub Desktop.
Save spacedmonkey/763005309cdb1c852ff57e5ccb71a57b to your computer and use it in GitHub Desktop.
$sql = "LIMIT 10";
$cache_key = md5($sql);
$post_ids = wp_cache_get( $cache_key, 'keystone_redirects' );
if( false === $post_ids ){
$post_ids = $wpdb->get_col( $sql );
$cache_time = (count($post_ids) > 0 ) ? MINUTE_IN_SECONDS : DAY_IN_SECONDS;
wp_cache_set( $cache_key, $post_ids, 'keystone_redirects', $cache_time );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment