Created
August 7, 2013 20:55
-
-
Save bjyoungblood/6178555 to your computer and use it in GitHub Desktop.
kohana cache using apc if available
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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