GravityView  1.19.4
The best, easiest way to display Gravity Forms entries on your website.
Public Member Functions | Data Fields | Protected Member Functions | Protected Attributes | Private Attributes
GravityView_Cache Class Reference

Handle caching using transients for GravityView. More...

Public Member Functions

 __construct ($form_ids=NULL, $args=array())
 
 add_hooks ()
 Add actions for clearing out caches when entries are updated. More...
 
 blacklist_add ($form_ids)
 Add form IDs to a "blacklist" to force the cache to be refreshed. More...
 
 blacklist_remove ($form_ids)
 Remove Form IDs from blacklist. More...
 
 delete ($form_ids=NULL)
 Delete cached transients based on form IDs. More...
 
 delete_expired_transients ()
 Delete expired transients. More...
 
 entry_created ($entry, $form)
 When an entry is created, add the entry's form to the cache blacklist. More...
 
 entry_updated ($form, $lead_id)
 When an entry is updated, add the entry's form to the cache blacklist. More...
 
 get ($key=NULL)
 Get transient result. More...
 
 get_key ()
 Allow public access to get transient key. More...
 
 in_blacklist ($form_ids=NULL)
 Is a form ID in the cache blacklist. More...
 
 schedule_transient_cleanup ()
 Schedule expired transient cleanup twice a day. More...
 
 set ($content, $filter_name= '')
 Cache content as a transient. More...
 
 use_cache ()
 Check whether to use cached results, if available. More...
 

Data Fields

const BLACKLIST_OPTION_NAME = 'gravityview_cache_blacklist'
 

Protected Member Functions

 get_cache_key_prefix ($form_ids=NULL)
 Calculate the prefix based on the Form IDs. More...
 
 set_key ()
 Set the transient key based on the form IDs and the arguments passed to the class. More...
 

Protected Attributes

 $args
 
 $form_ids
 

Private Attributes

 $key = ''
 
 $lead_db_columns = array( 'id', 'form_id', 'post_id', 'date_created', 'is_starred', 'is_read', 'ip', 'source_url', 'user_agent', 'currency', 'payment_status', 'payment_date', 'payment_amount', 'transaction_id', 'is_fulfilled', 'created_by', 'transaction_type', 'status' )
 

Detailed Description

Handle caching using transients for GravityView.

Definition at line 6 of file class-cache.php.

Constructor & Destructor Documentation

__construct (   $form_ids = NULL,
  $args = array() 
)
Parameters
array | int$form_idsForm ID or array of form IDs used in a request
array$argsExtra request parameters used to generate the query. This is used to generate the unique transient key.

Definition at line 42 of file class-cache.php.

References $args, $form_ids, add_hooks(), and set_key().

Member Function Documentation

add_hooks ( )

Add actions for clearing out caches when entries are updated.

Since
1.14
See also
RGFormsModel::update_lead_property() Trigger when any entry property changes

Definition at line 59 of file class-cache.php.

References $entry, and blacklist_add().

Referenced by __construct().

blacklist_add (   $form_ids)

Add form IDs to a "blacklist" to force the cache to be refreshed.

Parameters
int | array$form_idsForm IDs to force to be updated
Returns
boolean False if value was not updated and true if value was updated.

Definition at line 213 of file class-cache.php.

References $form_ids.

Referenced by add_hooks(), entry_created(), and entry_updated().

blacklist_remove (   $form_ids)

Remove Form IDs from blacklist.

Parameters
int | array$form_idsForm IDs to add
Returns
boolean Whether the removal was successful

Definition at line 241 of file class-cache.php.

References $form_ids.

Referenced by use_cache().

delete (   $form_ids = NULL)

Delete cached transients based on form IDs.

Parameters
int | array$form_idsForm IDs to delete
Returns
[type] [description]

Definition at line 374 of file class-cache.php.

References $form_id, $form_ids, $key, and get_cache_key_prefix().

delete_expired_transients ( )

Delete expired transients.

The code is copied from the Delete Expired Transients, with slight modifications to track # of results and to get the blog ID dynamically

See also
https://wordpress.org/plugins/delete-expired-transients/ Plugin where the code was taken from
DelxtransCleaners::clearBlogExpired()
Returns
void

Definition at line 444 of file class-cache.php.

entry_created (   $entry,
  $form 
)

When an entry is created, add the entry's form to the cache blacklist.

We don't want old caches; when an entry is added, we want to clear the cache.

Parameters
array$entryGF entry array
array$formGF form array
Returns
void

Definition at line 145 of file class-cache.php.

References $entry, $form, and blacklist_add().

entry_updated (   $form,
  $lead_id 
)

When an entry is updated, add the entry's form to the cache blacklist.

Parameters
array$formGF form array
int$lead_idEntry ID
Returns
void

Definition at line 128 of file class-cache.php.

References $form, and blacklist_add().

get (   $key = NULL)

Get transient result.

Parameters
string$keyTransient key to fetch
Returns
mixed False: Not using cache or cache was a WP_Error object; NULL: no results found; Mixed: cache value

Definition at line 299 of file class-cache.php.

References $key, and use_cache().

get_cache_key_prefix (   $form_ids = NULL)
protected

Calculate the prefix based on the Form IDs.

Parameters
int | array$form_idsForm IDs to generate prefix for
Returns
string Prefix for the cache string used in set_key()

Definition at line 159 of file class-cache.php.

References $form_ids, and $forms.

Referenced by delete(), and set_key().

get_key ( )

Allow public access to get transient key.

Returns
string Transient key

Definition at line 200 of file class-cache.php.

References $key.

in_blacklist (   $form_ids = NULL)

Is a form ID in the cache blacklist.

Parameters
int | array$form_idsForm IDs to check if in blacklist
Returns
[type] [description]

Definition at line 264 of file class-cache.php.

References $form_id, and $form_ids.

Referenced by use_cache().

schedule_transient_cleanup ( )

Schedule expired transient cleanup twice a day.

Can be overruled by the gravityview_cleanup_transients filter (returns boolean)

Returns
void
Runs Filter:
gravityview_cleanup_transients Override GravityView cleanup of transients by setting this to false
Parameters
boolean$cleanupWhether to run the GravityView auto-cleanup of transients. Default: true

Definition at line 418 of file class-cache.php.

set (   $content,
  $filter_name = '' 
)

Cache content as a transient.

Cache time defaults to 1 week

Parameters
[type]$content [description]
[type]$filter_name Name used to modify the cache time. Will be set to gravityview_cache_time_{$filter_name}.
Runs Filter:
gravityview_cache_time_{$filter_name} Modify the cache time for a type of cache
Parameters
int$time_in_secondsDefault: DAY_IN_SECONDS

Definition at line 341 of file class-cache.php.

References $content.

set_key ( )
protected

Set the transient key based on the form IDs and the arguments passed to the class.

Definition at line 179 of file class-cache.php.

References $key, and get_cache_key_prefix().

Referenced by __construct().

use_cache ( )

Check whether to use cached results, if available.

If the user can edit posts, they are able to override whether to cache results by adding cache or nocache to the URL requested.

Returns
boolean True: use cache; False: don't use cache
Runs Filter:
gravityview_use_cache Modify whether to use the cache or not
Parameters
[in,out]boolean$use_cachePrevious setting
[out]GravityView_Cache$thisThe GravityView_Cache object

Definition at line 494 of file class-cache.php.

References $form_ids, blacklist_remove(), GVCommon\has_cap(), and in_blacklist().

Referenced by get().

Field Documentation

$args
protected

Definition at line 22 of file class-cache.php.

Referenced by __construct().

$form_ids
protected
$key = ''
private

Definition at line 29 of file class-cache.php.

Referenced by delete(), get(), get_key(), and set_key().

$lead_db_columns = array( 'id', 'form_id', 'post_id', 'date_created', 'is_starred', 'is_read', 'ip', 'source_url', 'user_agent', 'currency', 'payment_status', 'payment_date', 'payment_amount', 'transaction_id', 'is_fulfilled', 'created_by', 'transaction_type', 'status' )
private

Definition at line 35 of file class-cache.php.

const BLACKLIST_OPTION_NAME = 'gravityview_cache_blacklist'

Definition at line 8 of file class-cache.php.


The documentation for this class was generated from the following file: