How do I conditionally override views cache using preview? I'm attempting to embed a view but need to disable the cache in this instance while leaving it enabled in other instances. I'm attmepting to do this using code but nothing I've tried seems to work. Here is my code so far:

  // Get the view and attach the handlers with the build call
  $view_object = views_get_view($view_name);
  $view_object-&gt;set_arguments($view_args);
  $view_object-&gt;build($view_display);

  // Manually editing the cache here does nothing
  //$view_object-&gt;display_handler-&gt;options['cache']['type'] = 'none';

  // Override option breaks the view object and the get plugin does nothing.
  $view_object-&gt;display_handler-&gt;override_option('cache', 'none');

  // Prints tell me that the previous two lines have not actualy changed the cache method.
  dsm($view_object-&gt;display_handler, 'display handler');
  dsm($view_object-&gt;display_handler-&gt;get_plugin('cache'), 'get plugin cache');

  // Returns the cached copy of the view despite changing the option.
  $view_object-&gt;execute($view_display);


Any views experts out there know how to override this cache option?
ADDITION:

This works:

$view=views_get_view('to_c_or_not_to_c'); // or whatever your name of your view is
$view-&gt;display['cached']-&gt;display_options['cache']=array('type' =&gt; 'none'); // 'cached' is the display name of the view that is normally cached but here we are going to set it to none
return $view-&gt;preview('cached'); // returns the rendered html of that display (if you need arguments, they can be passed here as an array in a second argument


ORIGINAL:

May the great drupal gods strike me down for this answer, but....

$view_object-&gt;live_preview=TRUE;


will cause drupal to ignore any cache()ing that may be set and a very quick look doesn't seem to show much other side effects (other than some query capturing)