定制 perturbatio/cachetags 二次开发

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

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

perturbatio/cachetags

Composer 安装命令:

composer require perturbatio/cachetags

包简介

Provides a partial caching mechanism for use with Laravel's Blade templating language or in normal PHP with the helpers

README 文档

README

CircleCI Latest Stable Version Latest Unstable Version License Total Downloads

This package is intended to allow you to cache portions of a web page by marking them using blade directives.

You can specify how long the partial will be cached for as well as naming it (to allow you to invalidate it if needed).

Nesting cacheTags is also possible, meaning that inner content will be cached at least as long as the outer cache is

Installation

Install it as a composer package with:

composer require perturbatio/cachetags

Add Perturbatio\CacheTags\CacheTagsProvider::class to your config/app.php providers array

Add 'CacheTags' => Perturbatio\CacheTags\CacheTags::class to your aliases

Then publish the config file with php artisan vendor:publish --tag=config this will create a cachetag.php config file in /config

Usage

Caching items

Blade

@cachetagStart('super-cool-widget', 15) <!-- widget cached for 15 minutes -->
<?=superCoolWidgetThatTakesTooLongToGenerate();?>

	@cachetagStart('other-cool-widget', 'forever') <!-- widget cached until something clears it, nested inside the outer cache -->
	<?=otherCoolWidgetThatTakesTooLongToGenerate();?>
	@cachetagEnd()
	
@cachetagEnd()

PHP

if ( cachetagHas('super-cool-widget') ){
	echo cachetagGet('super-cool-widget');
} else {
	cachetagStart('super-cool-widget', 15);
	echo superCoolWidgetThatTakesTooLongToGenerate();
  
		if ( cachetagHas('other-cool-widget') ){
			echo cachetagGet('other-cool-widget');
		} else {
			cachetagStart('other-cool-widget', 'forever'); //widget cached until something clears it, nested inside the outer cache 
			echo otherCoolWidgetThatTakesTooLongToGenerate();
			echo cachetagEnd();
		}
		
	echo cachetagEnd();
}

Clearing items

Blade

@cachetagClear('super-cool-widget')

PHP

//clear the cache for a specific key
cachetagClear('super-cool-widget');

if ( $otherCoolWidgetNeedsCacheInvalidated ){ //conditionally clear the 
	cachetagClear('other-cool-widget');
}

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2016-09-17

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固