Welcome Guest, Not a member yet? Register   Sign In
coddeigniter cache library
#1

[eluser]nani[/eluser]
Hi all !

i want to implement cache system to my website..

i found Phil SturgeonWeb cache library is a good one....

http://philsturgeon.co.uk/code/codeigniter-cache

if any one used this library please tell me how to implement this and any documentation for this.......

there is given a few lines of code on how to use this but, i need some clear description

please help me. i spend a lot time on searching for codeigniter caching....

Thank you...
#2

[eluser]Julio Fagundes[/eluser]
Its pretty simple.


Code:
Class Example extends CI_Controller
{

function foo()
{
  $this->load->library('cache');
  $cached['foo'] = $this->cache->model('example_model', 'get_data', array('any_param' = true), 120); // 2 minutes
}

Read the readme.txt file inside the zip, there are other examples.
#3

[eluser]nani[/eluser]
Thanks
where to use the cache call
before calling the model function or
after the model call or
i have to check for cache and if its not exist then i have call model function and then cache..

i have this doubts...please help me i'm first time implementing cache...

Code:
// cache modal call
$courses_list = $this->cache->model('get_course_data', 'simpleSearch', array($search_params), 120);
// call to the model function
$courses_list = $this->get_course_data->simpleSearch($search_params);

am i going wrong.....
#4

[eluser]Julio Fagundes[/eluser]
only this
Code:
$courses_list = $this->cache->model('get_course_data', 'simpleSearch', array($search_params), 120);

The cache library will call the model and make a cache for the next 2min (120seg)

The next call (another run of the script):
- if not exist a cache (or expired), $this->cache->model(...) will call the model, create a cache and return.
- if exist, $this->cache->model(...) will just return the cached value.


You can name your caches, in the case of query searchs I think is the best way.
read about it in the readme.txt




Theme © iAndrew 2016 - Forum software by © MyBB