@@ -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
| --- | --- | --- |
@@ -162,3 +162,51 @@ $this->typeList->cleanType($cacheKey);
162
162
163
163
[ tagscope] : {{ site.mage2bloburl }}/{{ page.guide_version }}/lib/internal/Magento/Framework/Cache/Frontend/Decorator/TagScope.php
164
164
[ type] : {{ site.mage2bloburl }}/{{ page.guide_version }}/app/code/Magento/Customer/Model/Cache/Type/Notification.php
165
+
166
+ ## Examples {#m2devgde-cache-type-model}
167
+
168
+ A cache type ` translate ` is declared in the Magento_Translation module using the ` cache.xml ` configuration file.
169
+
170
+ ``` xml
171
+ <config xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance" xsi : noNamespaceSchemaLocation =" urn:magento:framework:Cache/etc/cache.xsd" >
172
+ <type name =" translate" translate =" label,description" instance =" Magento\Framework\App\Cache\Type\Translate" >
173
+ <label >Translations</label >
174
+ <description >Translation files</description >
175
+ </type >
176
+ </config >
177
+ ```
178
+
179
+ Translate cache type model class is defined in ` Magento\Framework\App\Cache\Type\Translate.php ` class. It must extend the ` Magento\Framework\Cache\Frontend\Decorator\TagScope ` class.
180
+
181
+ ``` php
182
+ <?php
183
+ /**
184
+ * Copyright © Magento, Inc. All rights reserved.
185
+ * See COPYING.txt for license details.
186
+ */
187
+ namespace Magento\Framework\App\Cache\Type;
188
+
189
+ /**
190
+ * System / Cache Management / Cache type "Translations"
191
+ */
192
+ class Translate extends \Magento\Framework\Cache\Frontend\Decorator\TagScope
193
+ {
194
+ /**
195
+ * Cache type code unique among all cache types
196
+ */
197
+ const TYPE_IDENTIFIER = 'translate';
198
+
199
+ /**
200
+ * Cache tag used to distinguish the cache type from all other caches
201
+ */
202
+ const CACHE_TAG = 'TRANSLATE';
203
+
204
+ /**
205
+ * @param FrontendPool $cacheFrontendPool
206
+ */
207
+ public function __construct(FrontendPool $cacheFrontendPool)
208
+ {
209
+ parent::__construct($cacheFrontendPool->get(self::TYPE_IDENTIFIER), self::CACHE_TAG);
210
+ }
211
+ }
212
+ ```
0 commit comments