Automattic\WooCommerce\Internal\AddressProvider

AbstractAutomatticAddressProvider::is_expiredprivate staticWC 1.0

Checks if the cache value is expired.

Method of the class: AbstractAutomatticAddressProvider{}

No Hooks.

Returns

true|false. True if the contents are expired. False otherwise.

Usage

$result = AbstractAutomatticAddressProvider::is_expired( $cache_contents );
$cache_contents(array) (required)
The cache contents.

AbstractAutomatticAddressProvider::is_expired() code WC 10.3.3

private static function is_expired( $cache_contents ) {
	if ( ! is_array( $cache_contents ) || ! isset( $cache_contents['updated'] ) || ! isset( $cache_contents['ttl'] ) ) {
		// Treat bad/invalid cache contents as expired.
		return true;
	}

	// Double-check that we have integers for `updated` and `ttl`.
	if ( ! is_int( $cache_contents['updated'] ) || ! is_int( $cache_contents['ttl'] ) ) {
		return true;
	}

	$expires = $cache_contents['updated'] + $cache_contents['ttl'];
	$now     = time();
	return $expires < $now;
}