@@ -9,7 +9,7 @@ The tag *scope* provides a mechanism for a cache type.
9
9
10
10
## Cache type configuration {#m2devgde-cache-type-configuration}
11
11
12
- Declare a new cache type in the ` etc/cache.xml ` file with the following attributes:
12
+ Declare a new cache type in the ` <module_dir>/ etc/cache.xml` file with the following attributes:
13
13
14
14
| Attribute | Required? | Description |
15
15
| --- | --- | --- |
@@ -83,3 +83,51 @@ You must specify the following parameters:
83
83
84
84
[ tagscope] : {{ site.mage2bloburl }}/{{ page.guide_version }}/lib/internal/Magento/Framework/Cache/Frontend/Decorator/TagScope.php
85
85
[ type] : {{ site.mage2bloburl }}/{{ page.guide_version }}/app/code/Magento/Customer/Model/Cache/Type/Notification.php
86
+
87
+ ## Examples {#m2devgde-cache-type-model}
88
+
89
+ A cache type ` translate ` is declared in the Magento_Translation module using the ` cache.xml ` configuration file.
90
+
91
+ ``` xml
92
+ <config xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance" xsi : noNamespaceSchemaLocation =" urn:magento:framework:Cache/etc/cache.xsd" >
93
+ <type name =" translate" translate =" label,description" instance =" Magento\Framework\App\Cache\Type\Translate" >
94
+ <label >Translations</label >
95
+ <description >Translation files</description >
96
+ </type >
97
+ </config >
98
+ ```
99
+
100
+ Translate cache type model class is defined in ` Magento\Framework\App\Cache\Type\Translate.php ` class. It must extends ` Magento\Framework\Cache\Frontend\Decorator\TagScope ` class.
101
+
102
+ ``` php
103
+ <?php
104
+ /**
105
+ * Copyright © Magento, Inc. All rights reserved.
106
+ * See COPYING.txt for license details.
107
+ */
108
+ namespace Magento\Framework\App\Cache\Type;
109
+
110
+ /**
111
+ * System / Cache Management / Cache type "Translations"
112
+ */
113
+ class Translate extends \Magento\Framework\Cache\Frontend\Decorator\TagScope
114
+ {
115
+ /**
116
+ * Cache type code unique among all cache types
117
+ */
118
+ const TYPE_IDENTIFIER = 'translate';
119
+
120
+ /**
121
+ * Cache tag used to distinguish the cache type from all other cache
122
+ */
123
+ const CACHE_TAG = 'TRANSLATE';
124
+
125
+ /**
126
+ * @param FrontendPool $cacheFrontendPool
127
+ */
128
+ public function __construct(FrontendPool $cacheFrontendPool)
129
+ {
130
+ parent::__construct($cacheFrontendPool->get(self::TYPE_IDENTIFIER), self::CACHE_TAG);
131
+ }
132
+ }
133
+ ```
0 commit comments