Last active
July 7, 2016 11:24
-
-
Save Sanaldev/e4354fca19d4df9530c6a59a4e02547a to your computer and use it in GitHub Desktop.
A Simple class utilizing APC caching system
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
<? | |
class CacheAPC { | |
var $iTtl = 600; // Time To Live | |
var $bEnabled = false; // APC enabled? | |
// constructor | |
function CacheAPC() { | |
$this->bEnabled = extension_loaded('apc'); | |
} | |
// get data from memory | |
function getData($sKey) { | |
$bRes = false; | |
$vData = apc_fetch($sKey, $bRes); | |
return ($bRes) ? $vData :null; | |
} | |
// save data to memory | |
function setData($sKey, $vData) { | |
return apc_store($sKey, $vData, $this->iTtl); | |
} | |
// delete data from memory | |
function delData($sKey) { | |
return (apc_exists($sKey)) ? apc_delete($sKey) : true; | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment