Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #5 from gierschv/master

Add UNIX memcached socket support
  • Loading branch information...
commit e392332ebaa9eaf841c415ce0eab853c8513c625 2 parents 9c66cf8 + 02adec4
@beryllium authored
Showing with 17 additions and 13 deletions.
  1. +17 −13 Client/MemcacheClient.php
View
30 Client/MemcacheClient.php
@@ -6,11 +6,11 @@
/**
* Client interface for Memcache servers
- *
+ *
* @uses CacheClientInterface
- * @package
+ * @package
* @version $id$
- * @author Kevin Boyd <beryllium@beryllium.ca>
+ * @author Kevin Boyd <beryllium@beryllium.ca>
* @license See LICENSE.md
*/
class MemcacheClient implements CacheClientInterface
@@ -23,7 +23,7 @@ class MemcacheClient implements CacheClientInterface
/**
* Constructs the cache client using an injected Memcache instance
- *
+ *
* @access public
* @return void
*/
@@ -38,7 +38,7 @@ public function __construct( \Memcache $memcache )
* Does not probe server, does not set Safe to true.
*
* Should really be private, or modified to handle the probeServer action itself.
- *
+ *
* @param string $ip Location of memcache server
* @param int $port Optional: Port number (default: 11211)
* @access public
@@ -72,13 +72,17 @@ public function addServer( $ip, $port = 11211 )
*/
public function addServers( array $servers )
{
- if ( count( $servers ) == 0 )
+ if ( count( $servers ) == 0 )
{
return false;
}
foreach ( $servers as $ip=>$port )
{
+ if ( intval( $port ) == 0 )
+ {
+ $port = NULL;
+ }
if ( $this->probeServer( $ip, $port ) )
{
$status = $this->addServer( $ip, $port );
@@ -93,7 +97,7 @@ public function addServers( array $servers )
* The purpose of this is to verify that the server exists before trying to add it,
* to cut down on weird errors when doing ->get(). This could be a controversial or
* flawed way to go about this.
- *
+ *
* @param string $ip IP address (or hostname, possibly)
* @param int $port Port that memcache is running on
* @access public
@@ -118,8 +122,8 @@ public function probeServer( $ip, $port )
/**
* Retrieve a value from memcache
- *
- * @param string $key Unique identifier
+ *
+ * @param string $key Unique identifier
* @access public
* @return mixed Requested value, or false if an error occurs
*/
@@ -137,8 +141,8 @@ public function get( $key )
/**
* Add a value to the memcache
- *
- * @param string $key Unique key
+ *
+ * @param string $key Unique key
* @param mixed $value A value. I recommend a string, be it serialized or not - other values haven't been tested :)
* @param int $ttl Number of seconds for the value to be valid for
* @access public
@@ -158,7 +162,7 @@ public function set( $key, $value, $ttl )
/**
* Check if the cache is live
- *
+ *
* @access public
* @return True if a valid server has been added, otherwise false
*/
@@ -170,7 +174,7 @@ public function isSafe()
/**
* getStats returns the result of Memcache::getExtendedStats(), an associative array
* containing arrays of server stats
- *
+ *
* @access public
* @return array Server stats array
*/
Please sign in to comment.
Something went wrong with that request. Please try again.