PHP Class WC_Cache_Helper

Author: WooThemes
Exibir arquivo Open project: woocommerce/woocommerce Class Usage Examples

Public Methods

Method Description
delete_version_transients ( $version = '' ) When the transient version increases, this is used to remove all past transients to avoid filling the DB.
geolocation_ajax_get_location_hash ( ) : string Get a hash of the customer location.
geolocation_ajax_redirect ( ) When using geolocation via ajax, to bust cache, redirect if the location hash does not equal the querystring.
get_cache_prefix ( string $group ) : string Get prefix for use with wp_cache_set. Allows all cache in a group to be invalidated at once.
get_transient_version ( string $group, boolean $refresh = false ) : string Get transient version.
incr_cache_prefix ( string $group ) Increment group cache prefix (invalidates cache).
init ( ) Hook in methods.
notices ( ) notices function.
prevent_caching ( ) Prevent caching on dynamic pages.

Private Methods

Method Description
get_page_uris ( string $wc_page ) : array Get the page name/id for a WC page.
nocache ( ) Set nocache constants and headers.

Method Details

delete_version_transients() public static method

Note; this only works on transients appended with the transient version, and when object caching is not being used.
Since: 2.3.10
public static delete_version_transients ( $version = '' )

geolocation_ajax_get_location_hash() public static method

Get a hash of the customer location.
public static geolocation_ajax_get_location_hash ( ) : string
return string

geolocation_ajax_redirect() public static method

This prevents caching of the wrong data for this request.
public static geolocation_ajax_redirect ( )

get_cache_prefix() public static method

Get prefix for use with wp_cache_set. Allows all cache in a group to be invalidated at once.
public static get_cache_prefix ( string $group ) : string
$group string
return string

get_transient_version() public static method

When using transients with unpredictable names, e.g. those containing an md5. hash in the name, we need a way to invalidate them all at once. When using default WP transients we're able to do this with a DB query to. delete transients manually. With external cache however, this isn't possible. Instead, this function is used. to append a unique string (based on time()) to each transient. When transients. are invalidated, the transient version will increment and data will be regenerated. Raised in issue https://github.com/woocommerce/woocommerce/issues/5777. Adapted from ideas in http://tollmanz.com/invalidation-schemes/.
public static get_transient_version ( string $group, boolean $refresh = false ) : string
$group string Name for the group of transients we need to invalidate
$refresh boolean true to force a new version
return string transient version based on time(), 10 digits

incr_cache_prefix() public static method

Increment group cache prefix (invalidates cache).
public static incr_cache_prefix ( string $group )
$group string

init() public static method

Hook in methods.
public static init ( )

notices() public static method

notices function.
public static notices ( )

prevent_caching() public static method

Prevent caching on dynamic pages.
public static prevent_caching ( )