You are here

interface ImmutableInvalidationInterface in Purge 8.3

Describes the immutable invalidation.

Immutable invalidations are not used in real-life cache invalidation, as \Drupal\purge\Plugin\Purge\Purger\PurgersServiceInterface doesn't accept them. However, as they are read-only, they are used by user interfaces to see what is in the queue without actually claiming or changing it.

Hierarchy

Expanded class hierarchy of ImmutableInvalidationInterface

All classes that implement ImmutableInvalidationInterface

1 file declares its use of ImmutableInvalidationInterface
PluginTestBase.php in tests/src/Kernel/Invalidation/PluginTestBase.php

File

src/Plugin/Purge/Invalidation/ImmutableInvalidationInterface.php, line 15

Namespace

Drupal\purge\Plugin\Purge\Invalidation
View source
interface ImmutableInvalidationInterface extends InvStatesInterface, PluginInspectionInterface {

  /**
   * Return the string expression of the invalidation.
   *
   * @return string
   *   Returns the string serialization, e.g. "node/1".
   */
  public function __toString();

  /**
   * Get the invalidation expression.
   *
   * @return mixed|null
   *   Mixed expression (or NULL) that describes what needs to be invalidated.
   */
  public function getExpression();

  /**
   * Get all stored properties.
   *
   * @throws \LogicException
   *   Thrown when NOT operating in general context.
   *
   * @return array[]
   *   Associative array in which the keys point to purger instances and where
   *   each value represents a associative array with key-value stored metadata.
   */
  public function getProperties();

  /**
   * Retrieve a purger specific property value.
   *
   * Once ::setStateContext() has been called, purgers can call ::setProperty()
   * and ::getProperty() to store specific metadata on the invalidation. The
   * most common usecase for setting properties is for multi-step cache
   * invalidation, for instance CDNs returning IDs to check against later.
   *
   * @param string $key
   *   The key of the stored property, unique to the current purger context.
   *
   * @throws \LogicException
   *   Thrown when operating in general context, call ::setStateContext() first.
   *
   * @return null|mixed
   *   The property value or NULL when no such property exists.
   */
  public function getProperty($key);

  /**
   * Get the current or general state of the invalidation.
   *
   * New, freshly claimed invalidations and those exiting the PurgersService
   * always have NULL as their state context. This means that when called,
   * ::getState() resolves the general state by triaging all stored states. So
   * for example: when no states are known, it will evaluate to FRESH but when
   * one state is set to SUCCEEDED and a few others to FAILED, the general state
   * becomes FAILED. When only SUCCEEDED's is stored, it will evaluate as such.
   *
   * However, the behaviors of ::getState() and ::setState() change after a call
   * to ::setStateContext(). From this point on, both will respectively retrieve
   * and store the state *specific* to that purger context. Context switching is
   * handled by PurgersServiceInterface::invalidate() and therefore no
   * understanding of this concept is required outside the purgers service code.
   *
   * @throws \LogicException
   *   Thrown state are stored that should not have been stored, as is not
   *   never supposed to happen catching this exception is not recommended.
   *
   * @return int
   *   Any \Drupal\purge\Plugin\Purge\Invalidation\InvStatesInterface constant.
   */
  public function getState();

  /**
   * Get all stored state contexts.
   *
   * @throws \LogicException
   *   Thrown when NOT operating in general context.
   *
   * @return string[]
   *   Non-associative list of stored state contexts.
   */
  public function getStateContexts();

  /**
   * Get all invalidation states.
   *
   * @return int[]
   *   Associative list of which the keys refer to purger instances and the
   *   values from \Drupal\purge\Plugin\Purge\Invalidation\InvStatesInterface.
   */
  public function getStates();

  /**
   * Get the current state as string.
   *
   * @return string
   *   A capitalized string exactly matching the names of the constants in
   *   \Drupal\purge\Plugin\Purge\Invalidation\InvStatesInterface.
   */
  public function getStateString();

  /**
   * Get the current state as user translated string.
   *
   * @return \Drupal\Core\StringTranslation\TranslatableMarkup
   *   The translated string describing the current state of the invalidation.
   */
  public function getStateStringTranslated();

  /**
   * Get the type of invalidation.
   *
   * @return string
   *   The plugin ID of the invalidation.
   */
  public function getType();

}

Members

Namesort descending Modifiers Type Description Overrides
ImmutableInvalidationInterface::getExpression public function Get the invalidation expression. 1
ImmutableInvalidationInterface::getProperties public function Get all stored properties. 1
ImmutableInvalidationInterface::getProperty public function Retrieve a purger specific property value. 1
ImmutableInvalidationInterface::getState public function Get the current or general state of the invalidation. 1
ImmutableInvalidationInterface::getStateContexts public function Get all stored state contexts. 1
ImmutableInvalidationInterface::getStates public function Get all invalidation states. 1
ImmutableInvalidationInterface::getStateString public function Get the current state as string. 1
ImmutableInvalidationInterface::getStateStringTranslated public function Get the current state as user translated string. 1
ImmutableInvalidationInterface::getType public function Get the type of invalidation. 1
ImmutableInvalidationInterface::__toString public function Return the string expression of the invalidation. 1
InvStatesInterface::FAILED constant The invalidation failed and will be offered again later.
InvStatesInterface::FRESH constant Invalidation is new and no processing has been attempted on it yet.
InvStatesInterface::NOT_SUPPORTED constant The type of invalidation isn't supported and will be offered again later.
InvStatesInterface::PROCESSING constant The invalidation is processing.
InvStatesInterface::SUCCEEDED constant The invalidation succeeded.
PluginInspectionInterface::getPluginDefinition public function Gets the definition of the plugin implementation. 4
PluginInspectionInterface::getPluginId public function Gets the plugin_id of the plugin instance. 2