Commit 38a19388 by Carsten Brandt

documentation and code style fixes

parent fad01127
...@@ -24,7 +24,7 @@ class ApcCache extends Cache ...@@ -24,7 +24,7 @@ class ApcCache extends Cache
* Retrieves a value from cache with a specified key. * Retrieves a value from cache with a specified key.
* This is the implementation of the method declared in the parent class. * This is the implementation of the method declared in the parent class.
* @param string $key a unique key identifying the cached value * @param string $key a unique key identifying the cached value
* @return string the value stored in cache, false if the value is not in the cache or expired. * @return string|boolean the value stored in cache, false if the value is not in the cache or expired.
*/ */
protected function getValue($key) protected function getValue($key)
{ {
......
...@@ -247,7 +247,7 @@ abstract class Cache extends Component implements \ArrayAccess ...@@ -247,7 +247,7 @@ abstract class Cache extends Component implements \ArrayAccess
* This method should be implemented by child classes to retrieve the data * This method should be implemented by child classes to retrieve the data
* from specific cache storage. * from specific cache storage.
* @param string $key a unique key identifying the cached value * @param string $key a unique key identifying the cached value
* @return string the value stored in cache, false if the value is not in the cache or expired. * @return string|boolean the value stored in cache, false if the value is not in the cache or expired.
*/ */
abstract protected function getValue($key); abstract protected function getValue($key);
......
...@@ -92,7 +92,7 @@ class DbCache extends Cache ...@@ -92,7 +92,7 @@ class DbCache extends Cache
* Retrieves a value from cache with a specified key. * Retrieves a value from cache with a specified key.
* This is the implementation of the method declared in the parent class. * This is the implementation of the method declared in the parent class.
* @param string $key a unique key identifying the cached value * @param string $key a unique key identifying the cached value
* @return string the value stored in cache, false if the value is not in the cache or expired. * @return string|boolean the value stored in cache, false if the value is not in the cache or expired.
*/ */
protected function getValue($key) protected function getValue($key)
{ {
......
...@@ -24,7 +24,7 @@ class DummyCache extends Cache ...@@ -24,7 +24,7 @@ class DummyCache extends Cache
* Retrieves a value from cache with a specified key. * Retrieves a value from cache with a specified key.
* This is the implementation of the method declared in the parent class. * This is the implementation of the method declared in the parent class.
* @param string $key a unique key identifying the cached value * @param string $key a unique key identifying the cached value
* @return string the value stored in cache, false if the value is not in the cache or expired. * @return string|boolean the value stored in cache, false if the value is not in the cache or expired.
*/ */
protected function getValue($key) protected function getValue($key)
{ {
......
...@@ -61,7 +61,7 @@ class FileCache extends Cache ...@@ -61,7 +61,7 @@ class FileCache extends Cache
* Retrieves a value from cache with a specified key. * Retrieves a value from cache with a specified key.
* This is the implementation of the method declared in the parent class. * This is the implementation of the method declared in the parent class.
* @param string $key a unique key identifying the cached value * @param string $key a unique key identifying the cached value
* @return string the value stored in cache, false if the value is not in the cache or expired. * @return string|boolean the value stored in cache, false if the value is not in the cache or expired.
*/ */
protected function getValue($key) protected function getValue($key)
{ {
......
...@@ -145,7 +145,7 @@ class MemCache extends Cache ...@@ -145,7 +145,7 @@ class MemCache extends Cache
* Retrieves a value from cache with a specified key. * Retrieves a value from cache with a specified key.
* This is the implementation of the method declared in the parent class. * This is the implementation of the method declared in the parent class.
* @param string $key a unique key identifying the cached value * @param string $key a unique key identifying the cached value
* @return string the value stored in cache, false if the value is not in the cache or expired. * @return string|boolean the value stored in cache, false if the value is not in the cache or expired.
*/ */
protected function getValue($key) protected function getValue($key)
{ {
......
...@@ -49,11 +49,11 @@ class RedisCache extends Cache ...@@ -49,11 +49,11 @@ class RedisCache extends Cache
*/ */
public $hostname = 'localhost'; public $hostname = 'localhost';
/** /**
* @var int the to use for connecting to the redis server. Default port is 6379. * @var int the port to use for connecting to the redis server. Default port is 6379.
*/ */
public $port = 6379; public $port = 6379;
/** /**
* @var string the password to use to identify with the redis server. If not set, no AUTH command will be sent. * @var string the password to use to authenticate with the redis server. If not set, no AUTH command will be sent.
*/ */
public $password; public $password;
/** /**
...@@ -102,7 +102,7 @@ class RedisCache extends Cache ...@@ -102,7 +102,7 @@ class RedisCache extends Cache
* Retrieves a value from cache with a specified key. * Retrieves a value from cache with a specified key.
* This is the implementation of the method declared in the parent class. * This is the implementation of the method declared in the parent class.
* @param string $key a unique key identifying the cached value * @param string $key a unique key identifying the cached value
* @return string the value stored in cache, false if the value is not in the cache or expired. * @return string|boolean the value stored in cache, false if the value is not in the cache or expired.
*/ */
protected function getValue($key) protected function getValue($key)
{ {
......
...@@ -24,7 +24,7 @@ class WinCache extends Cache ...@@ -24,7 +24,7 @@ class WinCache extends Cache
* Retrieves a value from cache with a specified key. * Retrieves a value from cache with a specified key.
* This is the implementation of the method declared in the parent class. * This is the implementation of the method declared in the parent class.
* @param string $key a unique key identifying the cached value * @param string $key a unique key identifying the cached value
* @return string the value stored in cache, false if the value is not in the cache or expired. * @return string|boolean the value stored in cache, false if the value is not in the cache or expired.
*/ */
protected function getValue($key) protected function getValue($key)
{ {
......
...@@ -25,7 +25,7 @@ class XCache extends Cache ...@@ -25,7 +25,7 @@ class XCache extends Cache
* Retrieves a value from cache with a specified key. * Retrieves a value from cache with a specified key.
* This is the implementation of the method declared in the parent class. * This is the implementation of the method declared in the parent class.
* @param string $key a unique key identifying the cached value * @param string $key a unique key identifying the cached value
* @return string the value stored in cache, false if the value is not in the cache or expired. * @return string|boolean the value stored in cache, false if the value is not in the cache or expired.
*/ */
protected function getValue($key) protected function getValue($key)
{ {
......
...@@ -24,7 +24,7 @@ class ZendDataCache extends Cache ...@@ -24,7 +24,7 @@ class ZendDataCache extends Cache
* Retrieves a value from cache with a specified key. * Retrieves a value from cache with a specified key.
* This is the implementation of the method declared in the parent class. * This is the implementation of the method declared in the parent class.
* @param string $key a unique key identifying the cached value * @param string $key a unique key identifying the cached value
* @return string the value stored in cache, false if the value is not in the cache or expired. * @return string|boolean the value stored in cache, false if the value is not in the cache or expired.
*/ */
protected function getValue($key) protected function getValue($key)
{ {
......
...@@ -379,14 +379,13 @@ class Connection extends Component ...@@ -379,14 +379,13 @@ class Connection extends Component
case '-': // Error reply case '-': // Error reply
throw new Exception("Redis error: " . $line . "\nRedis command was: " . $command); throw new Exception("Redis error: " . $line . "\nRedis command was: " . $command);
case ':': // Integer reply case ':': // Integer reply
// no cast to integer as it is in the range of a signed 64 bit integer // no cast to int as it is in the range of a signed 64 bit integer
return $line; return $line;
case '$': // Bulk replies case '$': // Bulk replies
if ($line == '-1') { if ($line == '-1') {
return null; return null;
} }
$data = fread($this->_socket, $line + 2); if(($data = fread($this->_socket, $line + 2))===false) {
if($data===false) {
throw new Exception("Failed to read from socket.\nRedis command was: " . $command); throw new Exception("Failed to read from socket.\nRedis command was: " . $command);
} }
return substr($data, 0, -2); return substr($data, 0, -2);
......
...@@ -117,6 +117,7 @@ abstract class CacheTest extends TestCase ...@@ -117,6 +117,7 @@ abstract class CacheTest extends TestCase
$this->assertEquals(42, $cache->get('number_test')); $this->assertEquals(42, $cache->get('number_test'));
// should store data if it's not there yet // should store data if it's not there yet
$this->assertFalse($cache->get('add_test'));
$this->assertTrue($cache->add('add_test', 13)); $this->assertTrue($cache->add('add_test', 13));
$this->assertEquals(13, $cache->get('add_test')); $this->assertEquals(13, $cache->get('add_test'));
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment