Cache Drupal 8 Render Arrays
来源:互联网 发布:淘宝网招聘求职平台 编辑:程序博客网 时间:2024/05/21 10:13
Cacheability of render arrays.
How to Cache, clear cache (basend on time , tag) of a drupal 8 render array ?
Cache configuration of a renderer array (Just an exaple)
$render_array = [
'#markup' => 'Time : ' . date("H:i:s"),
'#cache' => [
'keys' => ['entity_view', 'node', $node->id()],
'contexts' => ['languages'],
'tags' => ['node:' . $node->id()],
'max-age' => \Drupal\Core\Cache\Cache::PERMANENT,
],
];
Example 1. Disable Cache of a render array.
$render_array = [
'#markup' => 'Time : ' . date("H:i:s"),
'#cache' => [
'disabled' => TRUE,
],
];
Example 2. Time Based Cache.
$render_array = [
'#markup' => 'Time : ' . date("H:i:s"),
'#cache' => [
'max_age'=> 0, //No cache (Like 'disabled' => TRUE,)
'max_age'=> 60, //60 seconds / 1 minute
'max_age'=> 3600, //3600 seconds / 1 hour
],
];
Example 3. Tags Based Cache.
$render_array = [
'#markup' => 'Time : ' . date("H:i:s"),
'#cache' => [
'tags' => ['your_module' . ':' . 'your_tag'],
],
];
Link : https://www.drupal.org/developing/api/8/render/arrays/cacheability
API : https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Render!theme.api.php/group/theme_render/8.2.x
- Cache Drupal 8 Render Arrays
- Guide to Drupal cache
- Understand Drupal's render and theme
- Render;
- render
- drupal 8 入门
- drupal
- drupal
- drupal
- Drupal
- Drupal
- drupal
- drupal 8 常见错误集锦
- Drupal 8 内核模块变化
- Drupal 8 常用模块介绍
- 清除drupal缓存cache 查看twig主题覆写文件 的方法
- Arrays
- Arrays
- STL总结
- 测试人员30岁前必须明白的2件事
- galleryfinal 实现Android图片单选/多选、拍照、裁剪、压缩。视频选择和录制。
- ThreadLocal
- HttpClient Post和Get请求实例+ 中文参数处理
- Cache Drupal 8 Render Arrays
- 阿里面试回来,想和Java程序员谈一谈
- SSH免密码登陆配置
- node.js 学习第十二天 utils
- 动态规划之Help Jimmy
- 关于 Java 中 finally 语句块的深度辨析
- r.js结合gulp等于webpack(angular为例)
- html+css的基本知识总结(一)
- 云主机 环境搭配 交接文档