themeplate/cache 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

themeplate/cache

Composer 安装命令:

composer require themeplate/cache

包简介

Convenient fragment caching methods

README 文档

README

Usage

use ThemePlate\Cache;

Cache::remember( 'unique_key', function() {
    return expensive_task();
}, MINUTE_IN_SECONDS );

Cache::forget( 'unique_key' );

Cache::file( 'special_key', 'path_to_file' );

$processor = Cache::processor();

$processor->report( function( $output ) {
    error_log( print_r( $output, true ) );
} );


function hourly_moment() {
    return 'to remember ' . time();
}

Cache::remember( 'unique_key', 'hourly_moment', HOUR_IN_SECONDS );

Force refresh value/s

<WP_HOME>/?tcs_refresh=<single_key>

<WP_HOME>/?tcs_refresh[]=<key1>&tcs_refresh[]=<key2>

works only when logged-in

Cache::remember( $key, $callback, $expiration )

Retrieve content from the cache or, if it doesn't exist, execute $callback and its result is returned then saved

  • $key (string)(Required) Unique cache key to use
  • $callback (callable)(Required) Function that returns data to store
  • $expiration (int)(Optional) Number of seconds before entry expires. Default 0 (forever)

Cache::forget( $key, $default )

Retrieve and delete the cache

  • $key (string)(Required) Unique cache key to use
  • $default (mixed)(Optional) To return if cache doesn't exist. Default null

Cache::file( $key, $path )

Like remember but, uses the file contents and no expiration, automatically updates if the file is modified instead

  • $key (string)(Required) Unique cache key to use
  • $path (string)(Required) Path of the file to read

Cache::processor()

Support for soft-expiration, Cache::remember* and Cache::file updates in the background

*Except for using anonymous function as callback (closure)

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: GPL-3.0-only
  • 更新时间: 2020-01-27

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固