• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Cache library

#11
[eluser]Lovecannon[/eluser]
Nah, it works just great for me.

#12
[eluser]geshan[/eluser]
How do I use this cache library with Ocular templating library?

#13
[eluser]Unknown[/eluser]
A very useful library, Thank you.

#14
[eluser]sophistry[/eluser]
this caching lib is more recent.

#15
[eluser]PermanaJ[/eluser]
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

#16
[eluser]kurucu[/eluser]
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.

#17
[eluser]Unknown[/eluser]
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 "<br /> Record : ". count($data);
$time_end = microtime(true);
$time = $time_end - $time_start;
echo "<br />Time spent : $time seconds\n";
?&gt;
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

#18
[eluser]displaynone[/eluser]
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:

Code:
function _file($cache_id, $cache_group = NULL)
{
  $hash = md5($cache_id);
  $path = $this->_group_dir($cache_group).'/'.substr($hash, 0, 1).'/'.substr($hash, 0, 2).'/';
  @mkdir($path, 0777, true);
  return $path.$hash;
}

Sorry form my english Wink


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.