Stores a form in the cache.
function form_set_cache($form_build_id, $form, $form_state) {
// 6 hours cache life time for forms should be plenty.
$expire = 21600;
// Cache form structure.
if (isset($form)) {
if ($GLOBALS['user']->uid) {
$form['#cache_token'] = drupal_get_token();
}
cache('form')
->set('form_' . $form_build_id, $form, REQUEST_TIME + $expire);
}
// Cache form state.
if ($data = array_diff_key($form_state, array_flip(form_state_keys_no_cache()))) {
cache('form')
->set('form_state_' . $form_build_id, $data, REQUEST_TIME + $expire);
}
}