Skip to content

What is the use of event_prefix and cache_tag variable magento 2 model file

When i am looking into magneto model files i find

<?php
namespace MageplazaHelloWorldModel;
class Post extends MagentoFrameworkModelAbstractModel implements MagentoFrameworkDataObjectIdentityInterface
{
    const CACHE_TAG = 'mageplaza_helloworld_post';

    protected $_cacheTag = 'mageplaza_helloworld_post';

    protected $_eventPrefix = 'mageplaza_helloworld_post';

    protected function _construct()
    {
        $this->_init('MageplazaHelloWorldModelResourceModelPost');
    }

    public function getIdentities()
    {
        return [self::CACHE_TAG . '_' . $this->getId()];
    }

    public function getDefaultValues()
    {
        $values = [];

        return $values;
    }
}

Here what is the use of const CACHE_TAG,$_cacheTag,$_eventPrefix. When we can use this variables.

Thanks.