weboftalent/imageeditpartialcachebust
Composer 安装命令:
composer require weboftalent/imageeditpartialcachebust
包简介
Simplify partial caching queries for folders of DataObjects associated with Images by cache busting these DataObjects when the associated image is edited
README 文档
README
##Partial Cache Busting After Image Editing
This module enables the updating of the LastEdited value of DataObjects associated with Images being edited. This simplifies partial caching of for example the rendering of a folder of pages which are each represented by an image. If the cache key is based on the LastEdited value of the DataObjects in the folder, then when an image is edited (e.g. refocused with the FocusPoint module) the change will not show, as the cache key knows nothing about the LastEdited field of the images of child pages.
The options to ensure image updates show in the above scenario when using partial caching are these:
- Use max(LastEdited) of all images - inefficient
- Have a parital cache query around each child page checking for the LastEdited field of the page's image. This is also inefficient as one database query is made per child page rendered.
- Add a method in the folder object to calculate the cache key based on a database join query.
At the expense of a slightly more expensive write, we can use the LastEdited date of the child pages as a cache key that will also take into account image edits.
##Configuration The classes to check for image IDs are configured as follows, in an arbitrarily named .yml file under any module's _config directory, e.g. imageeditpartialcachebust.yml. There are three keys under 'ImageEditCacheBust'
- Stages: the stages configured in your default configuration, the default being Stage and Live
- SiteTree: a nested array of ClassName mapped to the field containing the image ID.
- DataObject: a nested array of ClassName mapped to the field containing the image ID.
In the example below every time an image is refocussed every PageWithImage data object will have it's LastEdited field updated to now (thus busting fragment caches) if the value of MainImageID matches the ID of the image being edited. Similarly with both SlidePage and Staff, except this time checking the PhotoID field.
---
Name: imageeditpartialcachebuster
After: framework/routes#coreroutes
---
ImageEditCacheBust:
Stages: ['Stage','Live']
SiteTree:
PageWithImage : 'MainImageID'
Product : 'ImageID'
SlidePage : 'PhotoID'
Staff : 'PhotoID'
DataObject:
GalleryImage : 'ImageID'
##Template Example Using the module mentioned in the related modules section below, an example template for a folder containing several PageWithImage pages rendering their images looks like this:
<div class="row">
<div class="small-12 columns">
$BreadCrumbs
<h1>$Title</h1>
$Content
<% cached ID, LastEdited,Locale,$CacheKey('folderofpagewithimages','ChildPage') %>
<ul class="small-block-grid-2 medium-block-grid-3">
<% loop AllChildren %>
<li><div class="captionedImage">
<h3>$Title</h3>
<a href="$Link"><img class="shadowbox sliderImage" data-interchange="[$PortletImage.CroppedFocusedImage(390,260).URL, (default)],[$PortletImage.CroppedFocusedImage(236,157).URL, (small)],[$PortletImage.CroppedFocusedImage(236,157).URL, (medium)],[$PortletImage.CroppedFocusedImage(390,260).URL, (large)]"/>
<noscript><img src="$PortletImage.SetWidth(640).URL"></noscript></a>
</div>
</li>
<% end_loop %>
</ul>
<% end_cached %>
$Form
$PageComments
</div>
<% include TopAndLike %>
</div>
#Related Modules The cachkey helper module, https://github.com/gordonbanderson/weboftalent-cachekey-helper, enables all partial cache key values to be accessed in a single database query, vastly reducing the number of queries performed when checking for partial cache validity.
weboftalent/imageeditpartialcachebust 适用场景与选型建议
weboftalent/imageeditpartialcachebust 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 23 次下载、GitHub Stars 达 4, 最近一次更新时间为 2014 年 11 月 17 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「caching」 「templates」 「silverstripe」 「partials」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 weboftalent/imageeditpartialcachebust 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 weboftalent/imageeditpartialcachebust 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 weboftalent/imageeditpartialcachebust 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Shoot aims to make providing data to your templates more manageable
CakePHP 4.x AdminLTE Theme.
Bookdown.io With Bootswatch Styles And Prism Syntax Highlighting
Query caching for Laravel 5
CakePHP 3.x Gentelella Theme.
统计信息
- 总下载量: 23
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 4
- 点击次数: 22
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: Unknown
- 更新时间: 2014-11-17