Automattic\WooCommerce\Internal\Caches

CouponCodeLookupInvalidator::get_cache_key │ public │ WC 11.2.0

Get the object cache key holding the ids of the published coupons with the given code.

The key must be used with the cache group returned by get_cache_group().

Метод класса: CouponCodeLookupInvalidator{}

Хуков нет.

Возвращает

string. The cache key.

Использование

$CouponCodeLookupInvalidator = new CouponCodeLookupInvalidator();
$CouponCodeLookupInvalidator->get_cache_key( $code ): string;
$code(строка) (обязательный)
Coupon code.

Список изменений

С версии 11.2.0 Введена.

Код CouponCodeLookupInvalidator::get_cache_key() WC 11.3.0

public function get_cache_key( string $code ): string {
	// Coupon code allows spaces, which doesn't work well with some cache engines (e.g. memcached), hence the hashing.
	$hashed_code = md5( wc_strtolower( $code ) );

	return \WC_Cache_Helper::get_cache_prefix( self::CACHE_GROUP ) . 'coupon_id_from_code_' . $hashed_code;
}