GF_Results_Cache
Manages the entry results cache expiry and rebuild.
GF_Results_Cache::get_results() will attempt to calculate the results inside the time_limit arg. If incomplete then a WP Cron task is kicked off. If the cron task is unable to finish within time_limit_cron then another task is scheduled until the results are complete.
Source: includes/webapi/v2/includes/class-results-cache.php:18
Details
- Kind:
class - Namespace:
(global)
Methods
| Method | Description |
|---|---|
__construct() | GF_Results_Cache constructor. |
get_instance() | Returns an instance of this class, and stores it in the $_instance property. |
get_default_args() | Returns the default args for the results cache process. |
update_entry_status() | Callback for the gform_update_status action. |
entry_updated() | Callback for the gform_after_update_entry action. |
entry_created() | Callback for the gform_entry_created action. |
after_save_form() | Callback for the gform_after_save_form action. |
delete_cached_results() | Deletes all the cached results for the given form ID. |
get_results_cache_key_prefix() | Returns the prefix for the results cache option name. |
get_results_cache_key() | Generates a unique key for the cache meta based on form ID, fields and |
results_cron() | Recursive wp_cron task to continue the calculation of results. |
results_cron_is_scheduled() | Checks if the results cron job is currently scheduled |
get_results_cron_hook() | Returs the results cron hook name |
get_results() | Returns an array with the results for all the fields in the form. |
calculate() | Calculate a batch of entry results. |
Method Reference
__construct()
public function __construct()
GF_Results_Cache constructor.
Since: 2.4-beta-1
Source: includes/webapi/v2/includes/class-results-cache.php:25
get_instance()
public static function get_instance()
Returns an instance of this class, and stores it in the $_instance property.
Returns
- GF_Results_Cache — $_instance
Since: 2.4-beta-1
Source: includes/webapi/v2/includes/class-results-cache.php:53
get_default_args()
public function get_default_args()
Returns the default args for the results cache process.
Returns
array
Since: 2.4-beta-1 (time_limit - Max seconds allowed per batch. time_limit_cron - Max seconds allowed per batch while inside the cron task. page_size - Page size for each batch search results. callbacks - An array of callbacks. One supported callback: 'calculation' $cache_data, $form, $fields, $entries wait - Time in seconds to wait between each cron task. field_ids - An array of field IDs to include in the results.)
Source: includes/webapi/v2/includes/class-results-cache.php:75
update_entry_status()
public function update_entry_status( $entry_id )
Callback for the gform_update_status action.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$entry_id |
Since: 2.4-beta-1
Source: includes/webapi/v2/includes/class-results-cache.php:95
entry_updated()
public function entry_updated( $form, $entry_id )
Callback for the gform_after_update_entry action.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$form | |||
$entry_id |
Since: 2.4-beta-1
Source: includes/webapi/v2/includes/class-results-cache.php:110
entry_created()
public function entry_created( $entry, $form )
Callback for the gform_entry_created action.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$entry | |||
$form |
Since: 2.4-beta-1
Source: includes/webapi/v2/includes/class-results-cache.php:123
after_save_form()
public function after_save_form( $form, $is_new )
Callback for the gform_after_save_form action.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$form | |||
$is_new |
Since: 2.4-beta-1
Source: includes/webapi/v2/includes/class-results-cache.php:135
delete_cached_results()
public function delete_cached_results( $form_id )
Deletes all the cached results for the given form ID.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$form_id |
Returns
false|int|void
Since: 2.4-beta-1
Source: includes/webapi/v2/includes/class-results-cache.php:307
get_results_cache_key_prefix()
public function get_results_cache_key_prefix( $form_id )
Returns the prefix for the results cache option name.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$form_id |
Returns
string
Since: 2.4-beta-1
Source: includes/webapi/v2/includes/class-results-cache.php:333
get_results_cache_key()
public function get_results_cache_key( $form_id, $search_criteria=[] )
Generates a unique key for the cache meta based on form ID, fields and
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$form_id | |||
$search_criteria | [] |
Returns
string
Since: 2.4-beta-1
Source: includes/webapi/v2/includes/class-results-cache.php:354
results_cron()
public function results_cron( $form_id, $search_criteria, $args )
Recursive wp_cron task to continue the calculation of results.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$form_id | |||
$search_criteria | |||
$args |
Since: 2.4-beta-1
Source: includes/webapi/v2/includes/class-results-cache.php:371
results_cron_is_scheduled()
public function results_cron_is_scheduled( $form_id, $search_criteria, $args )
Checks if the results cron job is currently scheduled
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$form_id | |||
$search_criteria | |||
$args |
Returns
false|int
Since: 2.4-beta-1
Source: includes/webapi/v2/includes/class-results-cache.php:432
get_results_cron_hook()
public function get_results_cron_hook()
Returs the results cron hook name
Returns
string
Since: 2.4-beta-1
Source: includes/webapi/v2/includes/class-results-cache.php:446
get_results()
public function get_results( $form_id, $search_criteria=[], $args=[] )
Returns an array with the results for all the fields in the form.
If the results can be calculated within the time allowed in GFResults then the results are returned and nothing is cached. If the calculation has not finished then a single recursive wp_cron task will be scheduled for immediate execution. While the cache is being built by the wp_cron task this function will return the expired cache results if available or the latest step in the cache build. Add-On-specific results are not included e.g. grade frequencies in the Quiz Add-On.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$form_id | int | ||
$search_criteria | array | [] | |
$args | array | [] |
Returns
array|mixed|void
Since: 2.4-beta-1
Source: includes/webapi/v2/includes/class-results-cache.php:466
calculate()
public function calculate( $form, $search_criteria=[], $state_array=[], $args=[] )
Calculate a batch of entry results.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$form | |||
$search_criteria | array | [] | |
$state_array | array | [] | |
$args | array | [] |
Returns
array|mixed
Since: 2.4-beta-1
Source: includes/webapi/v2/includes/class-results-cache.php:569