From 5153d2839b9747aad7ca620602467f7210e5d298 Mon Sep 17 00:00:00 2001 From: icewing Date: Tue, 11 Mar 2008 15:03:36 +0000 Subject: Marcus Povey * ElggCache superclass git-svn-id: https://code.elgg.org/elgg/trunk@164 36083f99-b078-4883-b0ff-0f9b5a30f544 --- engine/lib/cache.php | 72 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 engine/lib/cache.php (limited to 'engine/lib') diff --git a/engine/lib/cache.php b/engine/lib/cache.php new file mode 100644 index 000000000..5a426cdee --- /dev/null +++ b/engine/lib/cache.php @@ -0,0 +1,72 @@ + + * @copyright Curverider Ltd 2008 + * @link http://elgg.org/ + */ + + /** + * @class ElggCache The elgg cache superclass. + * This defines the interface for a cache (wherever that cache is stored). + * @author Marcus Povey + */ + abstract class ElggCache + { + /** + * Variables for the cache object. + * + * @var array + */ + private $variables; + + /** + * Set the constructor. + */ + function __construct() { $this->variables = array(); } + + /** + * Set a cache variable. + * + * @param string $variable + * @param string $value + */ + public function set_variable($variable, $value) { $this->variables[$variable] = $value; } + + /** + * Get variables for this cache. + * + * @param string $variable + * @return mixed The variable or null; + */ + public function get_variable($variable) + { + if (isset($this->variables[$variable])) + return $this->variables[$variable]; + + return null; + } + + /** + * Save data in a cache. + * + * @param string $key + * @param string $data + * @return bool + */ + abstract public function save($key, $data); + + /** + * Load data from the cache using a given key. + * + * @param string $key + * @return mixed The stored data or false. + */ + abstract public function load($key); + } +?> \ No newline at end of file -- cgit v1.2.3