@@ -107,7 +107,7 @@ discard block |
||
| 107 | 107 | /** |
| 108 | 108 | * Obtain multiple cache items by their unique keys |
| 109 | 109 | * |
| 110 | - * @param array|Traversable $keys A list of keys that can obtained in a single operation. |
|
| 110 | + * @param string[] $keys A list of keys that can obtained in a single operation. |
|
| 111 | 111 | * |
| 112 | 112 | * @return array An array of key => value pairs. Cache keys that do not exist or are stale will have a value of null. |
| 113 | 113 | */ |
@@ -139,7 +139,7 @@ discard block |
||
| 139 | 139 | /** |
| 140 | 140 | * Delete multiple cache items in a single operation |
| 141 | 141 | * |
| 142 | - * @param array|Traversable $keys The array of string-based keys to be deleted |
|
| 142 | + * @param string[] $keys The array of string-based keys to be deleted |
|
| 143 | 143 | * |
| 144 | 144 | * @return bool True on success and false on failure |
| 145 | 145 | */ |
@@ -29,20 +29,20 @@ discard block |
||
| 29 | 29 | public function __construct(array $config) |
| 30 | 30 | { |
| 31 | 31 | $this->handler = new Redis(); |
| 32 | - $redisConfig= $this::$defaults; |
|
| 32 | + $redisConfig = $this::$defaults; |
|
| 33 | 33 | foreach ($config as $key=>$value) { |
| 34 | 34 | $redisConfig[$key] = $value; |
| 35 | 35 | } |
| 36 | 36 | if (file_exists('igbinary_serialize')) { |
| 37 | 37 | $this->serializer = Redis::SERIALIZER_IGBINARY; |
| 38 | 38 | } |
| 39 | - if ( isset($redisConfig['persistent']) && ($redisConfig['persistent'] === true)) { |
|
| 39 | + if (isset($redisConfig['persistent']) && ($redisConfig['persistent'] === true)) { |
|
| 40 | 40 | return $this->connect($redisConfig); |
| 41 | 41 | } |
| 42 | 42 | $this->persistentConnect($redisConfig); |
| 43 | 43 | } |
| 44 | 44 | |
| 45 | - private function connect( array $redisConfig){ |
|
| 45 | + private function connect(array $redisConfig) { |
|
| 46 | 46 | $this->handler->connect( |
| 47 | 47 | $redisConfig['host'], |
| 48 | 48 | $redisConfig['port'], |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | return $this->handler->select($redisConfig['dbIndex']); |
| 54 | 54 | } |
| 55 | 55 | |
| 56 | - private function persistentConnect( array $redisConfig){ |
|
| 56 | + private function persistentConnect(array $redisConfig) { |
|
| 57 | 57 | $this->handler->pconnect( |
| 58 | 58 | $redisConfig['host'], |
| 59 | 59 | $redisConfig['port'], |
@@ -86,20 +86,20 @@ discard block |
||
| 86 | 86 | * |
| 87 | 87 | * @return bool True on success and false on failure |
| 88 | 88 | */ |
| 89 | - public function set($key, $value, $ttl = null){ |
|
| 89 | + public function set($key, $value, $ttl = null) { |
|
| 90 | 90 | $ttl = intval($ttl); |
| 91 | 91 | $value = $this->serialize($value); |
| 92 | - if($ttl ==0 ){ |
|
| 92 | + if ($ttl == 0) { |
|
| 93 | 93 | return $this->handler->set($key, $value); |
| 94 | 94 | } |
| 95 | 95 | return $this->handler->set($key, $value, $ttl); |
| 96 | 96 | } |
| 97 | 97 | |
| 98 | - private function serialize($value){ |
|
| 98 | + private function serialize($value) { |
|
| 99 | 99 | return ($this->serializer === Redis::SERIALIZER_IGBINARY) ? igbinary_serialize($value) : serialize($value); |
| 100 | 100 | } |
| 101 | 101 | |
| 102 | - private function unserialize($value){ |
|
| 102 | + private function unserialize($value) { |
|
| 103 | 103 | return ($this->serializer === Redis::SERIALIZER_IGBINARY) ? igbinary_unserialize($value) : unserialize($value); |
| 104 | 104 | } |
| 105 | 105 | /** |
@@ -109,7 +109,7 @@ discard block |
||
| 109 | 109 | * |
| 110 | 110 | * @return bool True on success and false on failure |
| 111 | 111 | */ |
| 112 | - public function delete($key){ |
|
| 112 | + public function delete($key) { |
|
| 113 | 113 | return (bool) $this->handler->delete($key); |
| 114 | 114 | } |
| 115 | 115 | /** |
@@ -117,7 +117,7 @@ discard block |
||
| 117 | 117 | * |
| 118 | 118 | * @return bool True on success and false on failure |
| 119 | 119 | */ |
| 120 | - public function clear(){ |
|
| 120 | + public function clear() { |
|
| 121 | 121 | return $this->handler->flushDb(); |
| 122 | 122 | } |
| 123 | 123 | /** |
@@ -146,9 +146,9 @@ discard block |
||
| 146 | 146 | return $this->handler->mSet($items); |
| 147 | 147 | } |
| 148 | 148 | |
| 149 | - $return =[]; |
|
| 149 | + $return = []; |
|
| 150 | 150 | foreach ($items as $key=>$value) { |
| 151 | - $return[$key] = $this->set($key, $value, $ttl); |
|
| 151 | + $return[$key] = $this->set($key, $value, $ttl); |
|
| 152 | 152 | } |
| 153 | 153 | return $return; |
| 154 | 154 | } |
@@ -161,7 +161,7 @@ discard block |
||
| 161 | 161 | */ |
| 162 | 162 | public function deleteMultiple($keys) |
| 163 | 163 | { |
| 164 | - $return =[]; |
|
| 164 | + $return = []; |
|
| 165 | 165 | foreach ($keys as $key) { |
| 166 | 166 | $return[$key] = (bool) $this->delete($key); |
| 167 | 167 | } |
@@ -3,7 +3,7 @@ |
||
| 3 | 3 | |
| 4 | 4 | use Composer\Autoload\ClassLoader; |
| 5 | 5 | |
| 6 | -require_once dirname(__DIR__) . '/vendor/autoload.php'; |
|
| 6 | +require_once dirname(__DIR__).'/vendor/autoload.php'; |
|
| 7 | 7 | $loader = new ClassLoader(); |
| 8 | 8 | $loader->add('tests', dirname(__DIR__)); |
| 9 | 9 | $loader->register(); |
@@ -21,10 +21,10 @@ discard block |
||
| 21 | 21 | |
| 22 | 22 | public function testSetGetDeleteItem() |
| 23 | 23 | { |
| 24 | - $ins1 = $this->client->set('test1','value1'); |
|
| 24 | + $ins1 = $this->client->set('test1', 'value1'); |
|
| 25 | 25 | $this->assertTrue($ins1); |
| 26 | 26 | $value1 = $this->client->get('test1'); |
| 27 | - $this->assertEquals('value1',$value1); |
|
| 27 | + $this->assertEquals('value1', $value1); |
|
| 28 | 28 | $delete = $this->client->delete('test1'); |
| 29 | 29 | $this->assertTrue($delete); |
| 30 | 30 | } |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | $this->assertEquals(0, $counter_d_0); |
| 70 | 70 | } |
| 71 | 71 | |
| 72 | - public function testClear(){ |
|
| 72 | + public function testClear() { |
|
| 73 | 73 | $clear = $this->client->clear(); |
| 74 | 74 | $this->assertTrue($clear); |
| 75 | 75 | } |