ObjectCache::update_if_cached()publicWC 1.0

Update an object in the cache, but only if an object is already cached with the same id.

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

Хуков нет.


true|false. True on success, false on error or if no object wiith the supplied id was cached.


$ObjectCache = new ObjectCache();
$ObjectCache->update_if_cached( $object, $id, $expiration ): bool;
$object(объект|массив) (обязательный)
The new object that will replace the already cached one.
Id of the object to be cached, if null, get_object_id will be used to get it.
По умолчанию: null
Expiration of the cached data in seconds from the current time, or DEFAULT_EXPIRATION to use the default value.
По умолчанию: self::DEFAULT_EXPIRATION

Код ObjectCache::update_if_cached() WC 7.7.2

public function update_if_cached( $object, $id = null, int $expiration = self::DEFAULT_EXPIRATION ): bool {
	$id = $this->get_id_from_object_if_null( $object, $id );

	if ( ! $this->is_cached( $id ) ) {
		return false;

	return $this->set( $object, $id, $expiration );