Navigation

Touch

Yves has no connection to the database of Zed. This is a key concept to make rendering front-end pages fast. Yves fetches all dynamic data from a key-value storage (Redis) and a search engine (Elasticsearch).

This data includes, but is not limited to:

  • URL mappings
  • Product Information
  • Product Categories
  • Stock Information
  • Translations

The process of collecting data is triggered from a cronjob, but can also be executed manually. This process consists of two steps:

  • Touch data ( done through the Touch module )
  • Export data ( done through the Collector module)

Touch Data for Yves


Cascading Updates
Depending on what kind of data is changed, it can trigger cascade update of multiple resources. For example: renaming of a category will result in updating the URLs, category nodes, navigation and products.

The data that corresponds to the content stored in the key-value and search data storages can be changed through the back-end application interface ( Zed ). In order to have the client storage up to date with what’s currently in the Zed database, you must keep track of the changes and mark them accordingly.

The collector console commands gathers the items that changed in the SQL database and updates them in the front-end data storages. To keep track of the items that changed from the last update, Spryker uses a touch table. The touch table is a snapshot of the collection of items that changed during a specific interval.

For one entity, there’s one and only one corresponding row in the touch table. Every time an update is done to an entity that’s collected for Yves, the corresponding record from the touch table must be updated as well, so that after the update tasks have run, the change would also be reflected in the front-end application.

The data stored in the item_type column is a string that marks which collector knows how to collect that item. The collectors are differentiated by unique strings (e.g. categorynode items are collected by CategoryNodeCollector). The functionality that updates the touch entities is provided by the Touch module:

<?php
/**
 * @param string $itemType
 * @param int $idItem
 *
 * @return bool
 */
public function touchActive($itemType, $idItem)
public function touchInactive($itemType, $idItem)
public function touchDeleted($itemType, $idItem)

Example of usage for the TouchFacade operations:

<?php
/**
 * @param int $idUrl
 *
 * @return void
 */
public function touchUrlActive($idUrl)
{
    $this->touchFacade->touchActive(static::ITEM_TYPE_URL, $idUrl);
}

touchActive: Will force export of the existing related entity to corresponding Storage(s) on the next collector run.

touchDelete: Will try to delete entity by key from Storage(s) on the next collector run.

touchInactive: Will pause export of the existing related entity to corresponding Storage(s) on all future collector run.
This might be used, for example, during long update of entity in order to prevent export of partially updated data. At the beginning of update you call touchInactive, performing all required updates, and calling touchActive to export fully updated data to Storage(s).