Feb
16
2009
0

Cat_Cache

Cat Cache

My class for caching datas.

Click HERE for see the code of this class

This is a simple cache system written for php5 used for caching any type of data in files. It use all static method for render quickly the cache.

This class is able to manage data to be stored in cache files in a way that it may be safely stored and retrieved even when there may be many concurrent processes attempting to access the same data.

This is an example of the class uses:

< ?php
// Include the cache library
include('cat-cache.inc.php');

// Take te cache if exist
$options = array(
'cache_path' =>'/my-cache-path/',
'cache_lifetime' =>7200,
'cache_group' =>'news',
'cache_prefix' =>'_my_prefix'
);
if (!$content = Cat_Cache_Datas::get('unique id', $options)) {

$content = 'Bla bla bla';

Cat_Cache_Datas::save('unique id', $content, $options);
}
echo $content;

// Delete all group cache if is expired or not
$options = array(
'cache_path' =>'/my-cache-path/'
);
Cat_Cache_Datas::clean('my_group', false, $options);

// Delete all expired cache
$options = array(
'cache_path' =>'/my-cache-path/'
);
Cat_Cache_Datas::clean(false, false, $options);

// Delete all cache if is expired or not
$options = array(
'cache_path' =>'/my-cache-path/'
);
Cat_Cache_Datas::clean(false, true, $options);

// Delete ID cache if is expired or not
$options = array(
'cache_path' =>'/my-cache-path/'
);
Cat_Cache_Datas::del('my-cache-unique-id', $options);

// Take name of the ID cache
$options = array(
'cache_path' =>'/my-cache-path/'
);
Cat_Cache_Datas::get_name('my-cache-unique-id');
?>
download
Size: 4.9 KB
Hits : 18

Written by Davide in: Library, php | Tags: , ,

Theme: TheBuckmaker.com Magazine Style Templates