Skip to content

Instantly share code, notes, and snippets.

@bjyoungblood
Created August 7, 2013 20:55
Show Gist options
  • Save bjyoungblood/6178555 to your computer and use it in GitHub Desktop.
Save bjyoungblood/6178555 to your computer and use it in GitHub Desktop.
kohana cache using apc if available
public static function cache($name, $data = NULL, $lifetime = NULL)
{
if (function_exists('apc_store'))
return self::_apc_cache($name, $data, $lifetime);
return parent::cache($name, $data, $lifetime);
}
protected static function _apc_cache($name, $data = NULL, $lifetime = NULL)
{
if ($data === NULL)
{
$success = FALSE;
$val = apc_fetch($name, $success);
if ($success)
return unserialize($val);
else
return NULL;
}
return (bool) apc_store($name, serialize($data), $lifetime);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment