Page MenuHomeCode

No OneTemporary

diff --git a/includes/cache/cache.php b/includes/cache/cache.php
index ba1013e..8cd965a 100644
--- a/includes/cache/cache.php
+++ b/includes/cache/cache.php
@@ -1,46 +1,48 @@
<?php
/*
* Zed
* (c) 2010, Dereckson, some rights reserved
* Released under BSD license
*
* Cache calling class.
*
* 0.1 2010-07-06 22:45 Initial version [DcK]
*
*/
class Cache {
/*
* Gets the cache instance, initializing it if needed
* @eturn Cache the cache instance, or null if nothing is cached
*/
static function load () {
global $Config;
if (
!array_key_exists('cache', $Config) ||
!array_key_exists('engine', $Config['cache'])
) {
//cache is not configured or engine is not specified
- return null;
+ $engine = 'void';
+ } else {
+ //engine is specified in the configuration
+ $engine = $Config['cache']['engine'];
}
-
- $engine = $Config['cache']['engine'];
+
$engine_file = 'includes/cache/' . $engine . '.php';
$engine_class = 'Cache' . ucfirst($engine);
if (!file_exists($engine_file)) {
message_die(GENERAL_ERROR, "Can't initialize $engine cache engine.<br />$engine_file not found.", 'Cache');
}
require_once($engine_file);
if (!class_exists($engine_class)) {
message_die(GENERAL_ERROR, "Can't initialize $engine cache engine.<br />$engine_class class not found.", 'Cache');
}
return call_user_func(array($engine_class, 'load'));
}
}
?>
\ No newline at end of file
diff --git a/includes/cache/void.php b/includes/cache/void.php
new file mode 100644
index 0000000..c9b9264
--- /dev/null
+++ b/includes/cache/void.php
@@ -0,0 +1,54 @@
+<?php
+/*
+ * Zed
+ * (c) 2010, Dereckson, some rights reserved
+ * Released under BSD license
+ *
+ * Cache class: void
+ *
+ * 0.1 2010-07-06 22:55 Initial version [DcK]
+ *
+ * This class doesn't cache information, it'a void wrapper
+ * get will always return null
+ * set and delete do nothing
+ *
+ * This class implements a singleton pattern.
+ *
+ */
+
+class CacheVoid {
+ /*
+ * @var CacheVoid the current cache instance
+ */
+ static $instance = null;
+
+ /*
+ * Gets the cache instance, initializing it if needed
+ * @eturn Cache the cache instance, or null if nothing is cached
+ */
+ static function load () {
+ if (self::$instance === null) {
+ self::$instance = new CacheVoid();
+ }
+
+ return self::$instance;
+ }
+
+ /*
+ * Gets the specified key's data
+ */
+ function get ($key) {
+ return null;
+ }
+
+ /*
+ * Sets the specified data at the specified key
+ */
+ function set ($key, $value) { }
+
+ /*
+ * Deletes the specified key's data
+ */
+ function delete ($key) { }
+}
+?>
\ No newline at end of file

File Metadata

Mime Type
text/x-diff
Expires
Mon, Nov 4, 00:32 (3 w, 5 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
20951
Default Alt Text
(2 KB)

Event Timeline