emerge dev-php/PEAR-Cache_Lite
require_once "Cache/Lite.php"; define('ENABLE_CACHE_LITE',1); function _fn_get_data_from_cache($key) { $options = array( 'cacheDir' => '/tmp/', 'lifeTime' => 10, 'pearErrorMode' => CACHE_LITE_ERROR_DIE ); if (ENABLE_CACHE_LITE) { $cache=new Cache_Lite($options); if ($data=$cache->get($key)) { // got data from cache_lite then return return $data; } } // not found! then do the process // sample $data=time(); if (ENABLE_CACHE_LITE) { $cache->save($data); } return $data; } // ====== $key='abc'; echo _fn_get_data_from_cache($key);