* @copyright 2008 */ function xcache_cache_handler($action, &$smarty_obj, &$cache_content, $tpl_file = null, $cache_id = null, $compile_id = null) { if (function_exists('xcache_isset')) { $cacheid = 'smarty.'.$tpl_file.'@'.$cache_id.'@'.$compile_id; switch ($action) { case 'read': if (xcache_isset($cacheid)) { return xcache_get($cacheid); } else { return false; } case 'write': return xcache_set($cacheid, $cache_content, $smarty_obj->cache_lifetime); case 'clear': if (empty($cache_id) and empty($compile_id) and empty($tpl_file)) { return xcache_clear_cache(1, 0); } else { if (xcache_isset($cacheid)) { return xcache_unset($cacheid); } else { return false; } } default: $smarty_obj->trigger_error('cache_handler: unknown action "'.$action.'"' ); return false; } } else { $smarty_obj->trigger_error('cache_handler: Xcache not found!'); return false; } }