Skip to content

Instantly share code, notes, and snippets.

@minecrafter
Last active August 29, 2015 14:07
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save minecrafter/46673a1e4fefff622f6c to your computer and use it in GitHub Desktop.
Save minecrafter/46673a1e4fefff622f6c to your computer and use it in GitHub Desktop.
esoTalk APC caching plugin
<?php
/**
* An APC caching plugin for esoTalk. This does not do much on its own, due to limited esoTalk support for caching.
*
* 2014 Tux
*/
if (!defined("IN_ESOTALK")) exit;
ET::$pluginInfo["APCCache"] = array(
"name" => "APCCache",
"description" => "Allows the use of APC caching to speed up your forums.",
"version" => "0.1",
"author" => "The Chunk",
"authorEmail" => "support@thechunk.net",
"authorURL" => "http://thechunk,net",
"license" => "WTFPL"
);
/**
* The plugin.
*/
class ETPlugin_APCCache extends ETPlugin {
public function boot() {
ETFactory::register('cache', 'ETCache_APC');
}
}
/**
* The cache itself proper.
*/
class ETCache_APC {
function __construct() {
// Verify we can exist
if (!function_exists("apc_add")) {
throw new Exception("You must install APC.");
}
}
public function exists($key)
{
return apc_exists(C("esoTalk.cookie.name") . $key);
}
public function get($key)
{
return apc_fetch(C("esoTalk.cookie.name") . $key);
}
public function store($key, $value, $ttl = 0)
{
return apc_store(C("esoTalk.cookie.name") . $key, $value, $ttl);
}
public function remove($key)
{
return apc_delete(C("esoTalk.cookie.name") . $key);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment