Skip to content

Instantly share code, notes, and snippets.

@Sanaldev
Last active July 7, 2016 11:24
Show Gist options
  • Save Sanaldev/e4354fca19d4df9530c6a59a4e02547a to your computer and use it in GitHub Desktop.
Save Sanaldev/e4354fca19d4df9530c6a59a4e02547a to your computer and use it in GitHub Desktop.
A Simple class utilizing APC caching system
<?
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