Starting adding Redis support to Cache class
This commit is contained in:
parent
07d00289a1
commit
684ff2fef1
2 changed files with 54 additions and 34 deletions
|
@ -9,7 +9,7 @@
|
||||||
* Redistribution of these files must retain the above copyright notice.
|
* Redistribution of these files must retain the above copyright notice.
|
||||||
*
|
*
|
||||||
* @author Josh Sherman <pickles@joshtronic.com>
|
* @author Josh Sherman <pickles@joshtronic.com>
|
||||||
* @copyright Copyright 2007-2012, Josh Sherman
|
* @copyright Copyright 2007-2013, Josh Sherman
|
||||||
* @license http://www.opensource.org/licenses/mit-license.html
|
* @license http://www.opensource.org/licenses/mit-license.html
|
||||||
* @package PICKLES
|
* @package PICKLES
|
||||||
* @link https://github.com/joshtronic/pickles
|
* @link https://github.com/joshtronic/pickles
|
||||||
|
@ -18,21 +18,20 @@
|
||||||
/**
|
/**
|
||||||
* Cache Class
|
* Cache Class
|
||||||
*
|
*
|
||||||
* Wrapper class for Memcache() to allow for better error handling when the
|
* Wrapper class for interfacing with Redis and Memcached as key/value
|
||||||
* Memcached server is unavailable. Designed around the syntax for Memcached()
|
* stores for caching data. Wrapper provides graceful failover when a
|
||||||
* to allow for an easier transistion to the aforementioned in the future. I
|
* caching server is not available. The syntax is designed around the API
|
||||||
* don't entirely remember specifics, but the reason for not using Memcached()
|
* for Memcached() to provide a consistent experience across datastores.
|
||||||
* was due to an unexplainable bug in the version in the repository for Ubuntu
|
* Support for Memcached is currently using the Memcache() library due to
|
||||||
* 10.04 LTS. Memcached() does support more of the memcached protocol and will
|
* some bugginess with Memcached(). The plan is to migrate to Memcached()
|
||||||
* eventually be what PICKLES uses. Keys are forced to be uppercase for
|
* in the future. Redis interaction is done via phpredis. Keys are
|
||||||
* consistencies sake as I've been burned by the case sensitivity due to typos
|
* optionally namespaced and keys are forced to lowercase for consistency.
|
||||||
* in my code.
|
|
||||||
*
|
* @link http://www.memcached.org/
|
||||||
* Requires php5-memcache
|
|
||||||
*
|
|
||||||
* @link http://us.php.net/manual/en/book.memcache.php
|
* @link http://us.php.net/manual/en/book.memcache.php
|
||||||
* @link http://packages.ubuntu.com/lucid/php5-memcache
|
* @link http://packages.ubuntu.com/lucid/php5-memcache
|
||||||
* @link http://www.memcached.org/
|
* @link http://redis.io
|
||||||
|
* @link https://github.com/nicolasff/phpredis
|
||||||
*/
|
*/
|
||||||
class Cache extends Object
|
class Cache extends Object
|
||||||
{
|
{
|
||||||
|
@ -50,7 +49,15 @@ class Cache extends Object
|
||||||
* @access private
|
* @access private
|
||||||
* @var integer
|
* @var integer
|
||||||
*/
|
*/
|
||||||
private $port = 11211;
|
private $port = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Database to use (Redis-only)
|
||||||
|
*
|
||||||
|
* @access private
|
||||||
|
* @var integer
|
||||||
|
*/
|
||||||
|
private $database = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Namespace (prefix)
|
* Namespace (prefix)
|
||||||
|
@ -86,7 +93,10 @@ class Cache extends Object
|
||||||
{
|
{
|
||||||
$datasource = $this->config->datasources[$this->config->pickles['cache']];
|
$datasource = $this->config->datasources[$this->config->pickles['cache']];
|
||||||
|
|
||||||
foreach (array('hostname', 'port', 'namespace') as $variable)
|
var_dump($datasource);
|
||||||
|
exit;
|
||||||
|
|
||||||
|
foreach (array('hostname', 'port', 'database', 'namespace') as $variable)
|
||||||
{
|
{
|
||||||
if (isset($datasource[$variable]))
|
if (isset($datasource[$variable]))
|
||||||
{
|
{
|
||||||
|
@ -98,7 +108,7 @@ class Cache extends Object
|
||||||
|
|
||||||
if ($this->namespace != '')
|
if ($this->namespace != '')
|
||||||
{
|
{
|
||||||
$this->namespace .= '-';
|
$this->namespace .= ':';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
44
jar.php
44
jar.php
|
@ -588,7 +588,7 @@ class Browser extends Object
|
||||||
* Redistribution of these files must retain the above copyright notice.
|
* Redistribution of these files must retain the above copyright notice.
|
||||||
*
|
*
|
||||||
* @author Josh Sherman <pickles@joshtronic.com>
|
* @author Josh Sherman <pickles@joshtronic.com>
|
||||||
* @copyright Copyright 2007-2012, Josh Sherman
|
* @copyright Copyright 2007-2013, Josh Sherman
|
||||||
* @license http://www.opensource.org/licenses/mit-license.html
|
* @license http://www.opensource.org/licenses/mit-license.html
|
||||||
* @package PICKLES
|
* @package PICKLES
|
||||||
* @link https://github.com/joshtronic/pickles
|
* @link https://github.com/joshtronic/pickles
|
||||||
|
@ -597,21 +597,20 @@ class Browser extends Object
|
||||||
/**
|
/**
|
||||||
* Cache Class
|
* Cache Class
|
||||||
*
|
*
|
||||||
* Wrapper class for Memcache() to allow for better error handling when the
|
* Wrapper class for interfacing with Redis and Memcached as key/value
|
||||||
* Memcached server is unavailable. Designed around the syntax for Memcached()
|
* stores for caching data. Wrapper provides graceful failover when a
|
||||||
* to allow for an easier transistion to the aforementioned in the future. I
|
* caching server is not available. The syntax is designed around the API
|
||||||
* don't entirely remember specifics, but the reason for not using Memcached()
|
* for Memcached() to provide a consistent experience across datastores.
|
||||||
* was due to an unexplainable bug in the version in the repository for Ubuntu
|
* Support for Memcached is currently using the Memcache() library due to
|
||||||
* 10.04 LTS. Memcached() does support more of the memcached protocol and will
|
* some bugginess with Memcached(). The plan is to migrate to Memcached()
|
||||||
* eventually be what PICKLES uses. Keys are forced to be uppercase for
|
* in the future. Redis interaction is done via phpredis. Keys are
|
||||||
* consistencies sake as I've been burned by the case sensitivity due to typos
|
* optionally namespaced and keys are forced to lowercase for consistency.
|
||||||
* in my code.
|
|
||||||
*
|
* @link http://www.memcached.org/
|
||||||
* Requires php5-memcache
|
|
||||||
*
|
|
||||||
* @link http://us.php.net/manual/en/book.memcache.php
|
* @link http://us.php.net/manual/en/book.memcache.php
|
||||||
* @link http://packages.ubuntu.com/lucid/php5-memcache
|
* @link http://packages.ubuntu.com/lucid/php5-memcache
|
||||||
* @link http://www.memcached.org/
|
* @link http://redis.io
|
||||||
|
* @link https://github.com/nicolasff/phpredis
|
||||||
*/
|
*/
|
||||||
class Cache extends Object
|
class Cache extends Object
|
||||||
{
|
{
|
||||||
|
@ -629,7 +628,15 @@ class Cache extends Object
|
||||||
* @access private
|
* @access private
|
||||||
* @var integer
|
* @var integer
|
||||||
*/
|
*/
|
||||||
private $port = 11211;
|
private $port = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Database to use (Redis-only)
|
||||||
|
*
|
||||||
|
* @access private
|
||||||
|
* @var integer
|
||||||
|
*/
|
||||||
|
private $database = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Namespace (prefix)
|
* Namespace (prefix)
|
||||||
|
@ -665,7 +672,10 @@ class Cache extends Object
|
||||||
{
|
{
|
||||||
$datasource = $this->config->datasources[$this->config->pickles['cache']];
|
$datasource = $this->config->datasources[$this->config->pickles['cache']];
|
||||||
|
|
||||||
foreach (array('hostname', 'port', 'namespace') as $variable)
|
var_dump($datasource);
|
||||||
|
exit;
|
||||||
|
|
||||||
|
foreach (array('hostname', 'port', 'database', 'namespace') as $variable)
|
||||||
{
|
{
|
||||||
if (isset($datasource[$variable]))
|
if (isset($datasource[$variable]))
|
||||||
{
|
{
|
||||||
|
@ -677,7 +687,7 @@ class Cache extends Object
|
||||||
|
|
||||||
if ($this->namespace != '')
|
if ($this->namespace != '')
|
||||||
{
|
{
|
||||||
$this->namespace .= '-';
|
$this->namespace .= ':';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue