定制 imsamurai/cakephp-caching-behavior 二次开发

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

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

imsamurai/cakephp-caching-behavior

Composer 安装命令:

composer require imsamurai/cakephp-caching-behavior

包简介

Use it if you want to wrap model methods with cache

README 文档

README

Build Status Coverage Status Latest Stable Version Total Downloads Latest Unstable Version License

Caching Behaviour for CakePHP 2.1+

Use it if you want to wrap model methods with cache. For example you can use this for heavy model methods, that can't change output value for some time, but you need to invoke them very often.

Installation

cd my_cake_app/app
git clone git://github.com/imsamurai/cakephp-caching-behavior.git Plugin/Caching

or if you use git add as submodule:

cd my_cake_app
git submodule add "git://github.com/imsamurai/cakephp-caching-behavior.git" "app/Plugin/Caching"

then add plugin loading in Config/bootstrap.php

CakePlugin::load('Caching');

Configuration

Attach behaviour to model:

public $actsAs = array(
      'Caching.Caching' => array(
        'cache' => <valid cache config or name>, // optional
		'cachedObject' => <name of object class> // optional
      )
);

If cache is not specified in config and method cache() used 'default' cache config. By default for 'cachedObject' used 'Caching.CachedObject' that stored in Lib folder. You can use your own class, that must be in Lib folder of app or plugin. But remember that your class must have same interface.

Usage

After attaching behavior to your model you can do (assuming your model has methods something() and somethingElse()):

$Model->cached()->something(/*args*/);

or

$Model->cached(/*cache name*/)->something(/*args*/);

or

$CachedModel = $Model->cached(/*cache name or empty*/);
$CachedModel->something(/*args*/);
$CachedModel->somethingElse(/*args*/);

$Model->cached() returns object-wrapper that use magick methods and caching. So if expire date is ok, and you invoke same cached methods with same arguments and same cache config then model method calls only once.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2014-02-07

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固