Part of the EllisLab Network
   
2 of 2
2
Cache library
Posted: 18 July 2008 05:13 AM   [ Ignore ]   [ # 11 ]  
Grad Student
Avatar
Rank
Total Posts:  79
Joined  03-02-2008

How do I use this cache library with Ocular templating library?

 Signature 

Geshan Manandhar
http://geshan.blogspot.com

Profile
 
 
Posted: 17 December 2008 06:38 PM   [ Ignore ]   [ # 12 ]  
Summer Student
Total Posts:  1
Joined  07-29-2008

A very useful library, Thank you.

Profile
 
 
Posted: 17 December 2008 07:19 PM   [ Ignore ]   [ # 13 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1101
Joined  08-06-2006

this caching lib is more recent.

 Signature 

peeker email (imap/pop) | site_migrate | OOCalendar | PhotoBox2 | word_limiter

Profile
 
 
Posted: 11 June 2009 02:09 AM   [ Ignore ]   [ # 14 ]  
Grad Student
Rank
Total Posts:  45
Joined  12-10-2008

Hi, how can I save the cached data in application/cache folder instead of system/folder ? I have different CI folder structure .. here’s my folder structrure

> application
  - cache
  .. another folder

> system
  - cache
  .. another folder

Profile
 
 
Posted: 18 September 2009 04:02 PM   [ Ignore ]   [ # 15 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  123
Joined  08-21-2009

Wow. Nicely done! I was just about to implement something identical to this, and thought I’d go for a quick search. You’ve made exactly what I was planning! Thanks very much.

Edit: Within five minutes of installing it (which took two minutes) I have cached menus and pages working flawlessly. Great stuff.

Profile
 
 
Posted: 04 November 2009 05:12 AM   [ Ignore ]   [ # 16 ]  
Summer Student
Total Posts:  1
Joined  11-04-2009

I tried using your lib, I found problems, I hope that you can explain to me about it. Here is my code :

<?php

define(“BASEPATH”,$_SERVER[‘DOCUMENT_ROOT’].“cache_test/”);

include(“Cache.php”);
$cache = new Cache();
$ID=“1234425”;
$time_start = microtime(true);
if(!$data = $cache->get($ID)){
 
  $link = mysql_connect(“localhost”,“root”,”“);
  $conn = mysql_select_db(“ASF”,$link);
  $sSQL = “SELECT * FROM RESERVATION_SIMULATED”;
  $rs=mysql_query($sSQL);
  $count=0;
  while($row=mysql_fetch_array($rs)){
      $data[]=$row;
      $count++;
     
      if($count>40000){
        break;
      }
     
  }
  $cache->save($ID,$data);
  echo “cached successful”;
}
echo “
Record : “. count($data);
$time_end = microtime(true);
$time = $time_end - $time_start;
echo “
Time spent : $time seconds\n”;
?>
Here is the result
- The first time :
cached successful
Record : 40001
Time spent : 2.1360259056091 seconds

- The second time (after caching):

Record : 40001
Time spent : 4.4445600509644 seconds

Profile
 
 
Posted: 12 April 2011 04:40 AM   [ Ignore ]   [ # 17 ]  
Summer Student
Total Posts:  5
Joined  09-21-2007

I would like to suggest an improvement. If your application has to cache a huge amount of data, you can get directory problems (a lot of files in the same directory), so it’s a good idea to organizate the cache files in directories, p.e.:

[cache_path]/2/29/29df3630cbe4818d0569b346c527317f.cache
[cache_path]/2/29/29df3630cbe4818d0569b346c527317f.exp

So, I make this change:

function _file($cache_id$cache_group NULL)
{
  $hash 
md5($cache_id);
  
$path $this->_group_dir($cache_group).'/'.substr($hash01).'/'.substr($hash02).'/';
  @
mkdir($path0777true);
  return 
$path.$hash;

Sorry form my english wink

Profile
 
 
   
2 of 2
2