WordPress at Your Fingertips
function is not described

WC_Cache_Helper::get_transient_version() public WC 1.0

Get transient version.

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/.

{} It's a method of the class: WC_Cache_Helper{}

No Hooks.

Return

String. transient version based on time(), 10 digits.

Usage

$result = WC_Cache_Helper::get_transient_version( $group, $refresh );
$group(string) (required)
Name for the group of transients we need to invalidate.
$refresh(true|false)
true to force a new version.
Default: false

Code of WC_Cache_Helper::get_transient_version() WC 5.9.0

public static function get_transient_version( $group, $refresh = false ) {
	$transient_name  = $group . '-transient-version';
	$transient_value = get_transient( $transient_name );

	if ( false === $transient_value || true === $refresh ) {
		$transient_value = (string) time();

		set_transient( $transient_name, $transient_value );
	}

	return $transient_value;
}