定制 weboftalent/imageeditpartialcachebust 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

weboftalent/imageeditpartialcachebust

最新稳定版本:1.0.0

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 Build Status Scrutinizer Code Quality Code Coverage Build Status codecov.io

Latest Stable Version Latest Unstable Version Total Downloads License Monthly Downloads Daily Downloads

Dependency Status Reference Status

codecov.io

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.

统计信息

  • 总下载量: 23
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 4
  • 点击次数: 4
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 4
  • Watchers: 1
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: Unknown
  • 更新时间: 2014-11-17

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固