From 6a1cf8c035109f559a3a46399c74cb13fad5c724 Mon Sep 17 00:00:00 2001 From: Josh Sherman Date: Thu, 28 Feb 2013 12:24:02 -0500 Subject: [PATCH] Working on the caching Not sure how I got back on the master branch, meh. --- classes/Cache.php | 34 ++++++++++++++++++++++++---------- jar.php | 23 +++++++++++++++++++++++ 2 files changed, 47 insertions(+), 10 deletions(-) diff --git a/classes/Cache.php b/classes/Cache.php index 76dae6e..3b85fca 100644 --- a/classes/Cache.php +++ b/classes/Cache.php @@ -35,6 +35,9 @@ */ class Cache extends Object { + private $handler = null; + private $datasource = null; + /** * Hostname for the Memcached Server * @@ -93,22 +96,33 @@ class Cache extends Object { $datasource = $this->config->datasources[$this->config->pickles['cache']]; - var_dump($datasource); - exit; - - foreach (array('hostname', 'port', 'database', 'namespace') as $variable) + if (!isset($datasource['type'])) { - if (isset($datasource[$variable])) - { - $this->$variable = $datasource[$variable]; - } + throw new Exception('You must specify the datasource\'s type'); + } + + switch ($datasource['type']) + { + case 'memcache': + case 'memcached': + $this->handler = 'memcached'; + break; + + case 'redis': + $this->handler = 'redis'; + break; + + default: + throw new Exception('The specified datasource type "' . $datasource['type'] . '" is unsupported.'); } - } - } if ($this->namespace != '') { $this->namespace .= ':'; + } + + $this->datasource = $datasource; + } } } diff --git a/jar.php b/jar.php index 231a27c..faf4932 100755 --- a/jar.php +++ b/jar.php @@ -614,6 +614,9 @@ class Browser extends Object */ class Cache extends Object { + private $handler = null; + private $datasource = null; + /** * Hostname for the Memcached Server * @@ -672,6 +675,26 @@ class Cache extends Object { $datasource = $this->config->datasources[$this->config->pickles['cache']]; + if (!isset($datasource['type'])) + { + throw new Exception('You must specify the datasource\'s type'); + } + + switch ($datasource['type']) + { + case 'memcache': + case 'memcached': + $this->handler = 'memcached'; + break; + + case 'redis': + $this->handler = 'redis'; + break; + + default: + throw new Exception('The specified datasource type "' . $datasource['type'] . '" is unsupported.'); + } + var_dump($datasource); exit;