Magento 2 : How to create your own cache type ?

Create your own cache type is common business requirement. Today we gonna learn how to create custom cache type which not only cache the data object but you can also delete cached data from the Magento backend Cache Management.

Bajaj/CustomCache/etc/cache.xml

Bajaj/CustomCache/Model/Cache/Type.php

Bajaj Custom Cache Type

To enable the custom cache type run the following command:

bin/magento cache:enable bajaj_custom_cache

So when you run bin/magento cache:clean bajaj_custom_cache for example, all cached data with the BAJAJ_CUSTOM_CACHE tag are deleted.