2017 © Pedro Peláez
 

cakephp-plugin cakephp-caching-behavior

Use it if you want to wrap model methods with cache

image

imsamurai/cakephp-caching-behavior

Use it if you want to wrap model methods with cache

  • Friday, February 7, 2014
  • by imsamurai
  • Repository
  • 1 Watchers
  • 3 Stars
  • 11 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

CakePHP Caching Behaviour

Build Status Coverage Status Latest Stable Version Total Downloads Latest Unstable Version License, (*1)

Caching Behaviour for CakePHP 2.1+, (*2)

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., (*3)

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:, (*4)

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, (*5)

CakePlugin::load('Caching');

Configuration

Attach behaviour to model:, (*6)

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., (*7)

Usage

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

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

or, (*9)

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

or, (*10)

$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., (*11)

The Versions

07/02 2014

dev-master

9999999-dev http://github.com/imsamurai/cakephp-caching-behavior

Use it if you want to wrap model methods with cache

  Sources   Download

MIT

The Requires

 

cakephp caching behaviour

07/02 2014

1.0.0

1.0.0.0 http://github.com/imsamurai/cakephp-caching-behavior

Use it if you want to wrap model methods with cache

  Sources   Download

MIT

The Requires

 

cakephp caching behaviour