callcache Auto cache the function return value.

  1. Requirements
  2. Usage
  3. Resources

Generic Implementation : Memoize.php

This extension can be used to cache function or method output in Memcache or other cache you specified.Usually,some functions's call will connect to the database,compute the result base many data records,these operation will waste much time,and lot of them can be cached(Maybe you even do this though memcache api or Yii::app()->cache->set manually).For example,select user's profiles from the database,the result should be cache in memory and keep 2 minutes than expires(or until the user modified his profiles).


You should specify a cache components at least.


CacheDecor is a configurable components.Just one php file. You can put it in your app components directory and add it to components config:

        'cacheID'=>'cache',//You must specify one cache component at leat.

When you want to call a function with automatically cache,you can use

//Call a function
//Or a method

Another usage,it can auto decorate a method call. But this way may be obtrusive.You must use a method prefix.So I do not introduct it for more.

For more usage and config documentation,please read the comment in the php file.

Here is a post about memoization in php:

Also,in the archive,I upload the TestCase besides the CacheDecor class. TestCase shows more usage of class CacheDecor.


7 0
Yii Version: all
License: BSD-2-Clause
Category: Caching
Tags: Cache, Memoize
Developed by: Jam
Created on: Dec 17, 2010
Last updated: 7 years ago


show all

Related Extensions