ScandiPWA controls cache in a different way than does. We are still using the caching identities, but, instead of specifying them on GraphQL queries we use events.
General rule
To make some of your model work as cache identity manager:
Make sure it implements the Magento\Framework\DataObject\IdentityInterface
use Magento\Framework\DataObject\IdentityInterface;
use Magento\Framework\Model\AbstractModel;
class Slide extends AbstractModel implements IdentityInterface {
public function getIdentities() {
// TODO: implement
}
}
2. Specify the caching tag constant, it should be short and unique:
3. Implement the getIdentities method, specify all involved cache identities. In our example, on slide save, the slider model should also be invalidate:
class Slide extends AbstractModel implements IdentityInterface {
const CACHE_TAG = 'sw_sld';
public function getIdentities() {
return [
self::CACHE_TAG . '_' . $this->getId(),
Slider::CACHE_TAG . '_' . $this->getSliderId()
];
}
}
4. Add the names for events, prefer unique, descriptive names: