Completed
Push — V6 ( e9a4a9...c00b85 )
by Georges
02:18
created
src/phpFastCache/Drivers/Cassandra/Driver.php 4 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -57,7 +57,7 @@
 block discarded – undo
57 57
 
58 58
     /**
59 59
      * @param \Psr\Cache\CacheItemInterface $item
60
-     * @return mixed
60
+     * @return boolean
61 61
      * @throws \InvalidArgumentException
62 62
      */
63 63
     public function driverWrite(CacheItemInterface $item)
Please login to merge, or discard this patch.
Indentation   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -74,16 +74,16 @@  discard block
 block discarded – undo
74 74
         if ($item instanceof Item) {
75 75
             $cacheData = $this->encode($this->driverPreWrap($item));
76 76
             $options = new Cassandra\ExecutionOptions([
77
-              'arguments' => [
77
+                'arguments' => [
78 78
                 'cache_uuid' => new Cassandra\Uuid(),
79 79
                 'cache_id' => $item->getKey(),
80 80
                 'cache_data' => $this->encode($this->driverPreWrap($item)),
81 81
                 'cache_creation_date' => new Cassandra\Timestamp((new \DateTime())->getTimestamp()),
82 82
                 'cache_expiration_date' => new Cassandra\Timestamp($item->getExpirationDate()->getTimestamp()),
83 83
                 'cache_length' => strlen($cacheData)
84
-              ],
85
-              'consistency' => Cassandra::CONSISTENCY_ALL,
86
-              'serial_consistency' => Cassandra::CONSISTENCY_SERIAL
84
+                ],
85
+                'consistency' => Cassandra::CONSISTENCY_ALL,
86
+                'serial_consistency' => Cassandra::CONSISTENCY_SERIAL
87 87
             ]);
88 88
 
89 89
             $query = sprintf('INSERT INTO %s.%s
@@ -118,13 +118,13 @@  discard block
 block discarded – undo
118 118
     {
119 119
         try {
120 120
             $options = new Cassandra\ExecutionOptions([
121
-              'arguments' => ['cache_id' => $item->getKey()],
122
-              'page_size' => 1
121
+                'arguments' => ['cache_id' => $item->getKey()],
122
+                'page_size' => 1
123 123
             ]);
124 124
             $query = sprintf(
125
-              'SELECT cache_data FROM %s.%s WHERE cache_id = :cache_id;',
126
-              self::CASSANDRA_KEY_SPACE,
127
-              self::CASSANDRA_TABLE
125
+                'SELECT cache_data FROM %s.%s WHERE cache_id = :cache_id;',
126
+                self::CASSANDRA_KEY_SPACE,
127
+                self::CASSANDRA_TABLE
128 128
             );
129 129
             $results = $this->instance->execute(new Cassandra\SimpleStatement($query), $options);
130 130
 
@@ -151,14 +151,14 @@  discard block
 block discarded – undo
151 151
         if ($item instanceof Item) {
152 152
             try {
153 153
                 $options = new Cassandra\ExecutionOptions([
154
-                  'arguments' => [
154
+                    'arguments' => [
155 155
                     'cache_id' => $item->getKey(),
156
-                  ],
156
+                    ],
157 157
                 ]);
158 158
                 $result = $this->instance->execute(new Cassandra\SimpleStatement(sprintf(
159
-                  'DELETE FROM %s.%s WHERE cache_id = :cache_id;',
160
-                  self::CASSANDRA_KEY_SPACE,
161
-                  self::CASSANDRA_TABLE
159
+                    'DELETE FROM %s.%s WHERE cache_id = :cache_id;',
160
+                    self::CASSANDRA_KEY_SPACE,
161
+                    self::CASSANDRA_TABLE
162 162
                 )), $options);
163 163
 
164 164
                 /**
@@ -182,8 +182,8 @@  discard block
 block discarded – undo
182 182
     {
183 183
         try {
184 184
             $result = $this->instance->execute(new Cassandra\SimpleStatement(sprintf(
185
-              'TRUNCATE %s.%s;',
186
-              self::CASSANDRA_KEY_SPACE, self::CASSANDRA_TABLE
185
+                'TRUNCATE %s.%s;',
186
+                self::CASSANDRA_KEY_SPACE, self::CASSANDRA_TABLE
187 187
             )));
188 188
             /**
189 189
              * There's no real way atm
@@ -211,8 +211,8 @@  discard block
 block discarded – undo
211 211
             $username = isset($this->config[ 'username' ]) ? $this->config[ 'username' ] : '';
212 212
 
213 213
             $clusterBuilder = Cassandra::cluster()
214
-              ->withContactPoints($host)
215
-              ->withPort($port);
214
+                ->withContactPoints($host)
215
+                ->withPort($port);
216 216
 
217 217
             if(!empty($this->config['ssl']['enabled'])){
218 218
                 if(!empty($this->config['ssl']['verify'])){
@@ -240,8 +240,8 @@  discard block
 block discarded – undo
240 240
              */
241 241
 
242 242
             $this->instance->execute(new Cassandra\SimpleStatement(sprintf(
243
-              "CREATE KEYSPACE IF NOT EXISTS %s WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor' : 1 };",
244
-              self::CASSANDRA_KEY_SPACE
243
+                "CREATE KEYSPACE IF NOT EXISTS %s WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor' : 1 };",
244
+                self::CASSANDRA_KEY_SPACE
245 245
             )));
246 246
             $this->instance->execute(new Cassandra\SimpleStatement(sprintf('USE %s;', self::CASSANDRA_KEY_SPACE)));
247 247
             $this->instance->execute(new Cassandra\SimpleStatement(sprintf('
@@ -272,15 +272,15 @@  discard block
 block discarded – undo
272 272
     public function getStats()
273 273
     {
274 274
         $result = $this->instance->execute(new Cassandra\SimpleStatement(sprintf(
275
-          'SELECT SUM(cache_length) as cache_size FROM %s.%s',
276
-          self::CASSANDRA_KEY_SPACE,
277
-          self::CASSANDRA_TABLE
275
+            'SELECT SUM(cache_length) as cache_size FROM %s.%s',
276
+            self::CASSANDRA_KEY_SPACE,
277
+            self::CASSANDRA_TABLE
278 278
         )));
279 279
 
280 280
         return (new driverStatistic())
281
-          ->setSize($result->first()[ 'cache_size' ])
282
-          ->setRawData([])
283
-          ->setData(implode(', ', array_keys($this->itemInstances)))
284
-          ->setInfo('The cache size represents only the cache data itself without counting data structures associated to the cache entries.');
281
+            ->setSize($result->first()[ 'cache_size' ])
282
+            ->setRawData([])
283
+            ->setData(implode(', ', array_keys($this->itemInstances)))
284
+            ->setInfo('The cache size represents only the cache data itself without counting data structures associated to the cache entries.');
285 285
     }
286 286
 }
287 287
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -128,9 +128,9 @@  discard block
 block discarded – undo
128 128
             );
129 129
             $results = $this->instance->execute(new Cassandra\SimpleStatement($query), $options);
130 130
 
131
-            if($results instanceof Cassandra\Rows && $results->count() === 1){
131
+            if ($results instanceof Cassandra\Rows && $results->count() === 1) {
132 132
                 return $this->decode($results->first()['cache_data']);
133
-            }else{
133
+            } else {
134 134
                 return null;
135 135
             }
136 136
         } catch (Cassandra\Exception $e) {
@@ -204,20 +204,20 @@  discard block
 block discarded – undo
204 204
         if ($this->instance instanceof CouchbaseClient) {
205 205
             throw new \LogicException('Already connected to Couchbase server');
206 206
         } else {
207
-            $host = isset($this->config[ 'host' ]) ? $this->config[ 'host' ] : '127.0.0.1';
208
-            $port = isset($this->config[ 'port' ]) ? $this->config[ 'port' ] : 9042;
209
-            $timeout = isset($this->config[ 'timeout' ]) ? $this->config[ 'timeout' ] : 2;
210
-            $password = isset($this->config[ 'password' ]) ? $this->config[ 'password' ] : '';
211
-            $username = isset($this->config[ 'username' ]) ? $this->config[ 'username' ] : '';
207
+            $host = isset($this->config['host']) ? $this->config['host'] : '127.0.0.1';
208
+            $port = isset($this->config['port']) ? $this->config['port'] : 9042;
209
+            $timeout = isset($this->config['timeout']) ? $this->config['timeout'] : 2;
210
+            $password = isset($this->config['password']) ? $this->config['password'] : '';
211
+            $username = isset($this->config['username']) ? $this->config['username'] : '';
212 212
 
213 213
             $clusterBuilder = Cassandra::cluster()
214 214
               ->withContactPoints($host)
215 215
               ->withPort($port);
216 216
 
217
-            if(!empty($this->config['ssl']['enabled'])){
218
-                if(!empty($this->config['ssl']['verify'])){
217
+            if (!empty($this->config['ssl']['enabled'])) {
218
+                if (!empty($this->config['ssl']['verify'])) {
219 219
                     $sslBuilder = Cassandra::ssl()->withVerifyFlags(Cassandra::VERIFY_PEER_CERT);
220
-                }else{
220
+                } else {
221 221
                     $sslBuilder = Cassandra::ssl()->withVerifyFlags(Cassandra::VERIFY_NONE);
222 222
                 }
223 223
 
@@ -226,7 +226,7 @@  discard block
 block discarded – undo
226 226
 
227 227
             $clusterBuilder->withConnectTimeout($timeout);
228 228
 
229
-            if($username){
229
+            if ($username) {
230 230
                 $clusterBuilder->withCredentials($username, $password);
231 231
             }
232 232
 
@@ -278,7 +278,7 @@  discard block
 block discarded – undo
278 278
         )));
279 279
 
280 280
         return (new driverStatistic())
281
-          ->setSize($result->first()[ 'cache_size' ])
281
+          ->setSize($result->first()['cache_size'])
282 282
           ->setRawData([])
283 283
           ->setData(implode(', ', array_keys($this->itemInstances)))
284 284
           ->setInfo('The cache size represents only the cache data itself without counting data structures associated to the cache entries.');
Please login to merge, or discard this patch.
Braces   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
 
131 131
             if($results instanceof Cassandra\Rows && $results->count() === 1){
132 132
                 return $this->decode($results->first()['cache_data']);
133
-            }else{
133
+            } else{
134 134
                 return null;
135 135
             }
136 136
         } catch (Cassandra\Exception $e) {
@@ -217,7 +217,7 @@  discard block
 block discarded – undo
217 217
             if(!empty($this->config['ssl']['enabled'])){
218 218
                 if(!empty($this->config['ssl']['verify'])){
219 219
                     $sslBuilder = Cassandra::ssl()->withVerifyFlags(Cassandra::VERIFY_PEER_CERT);
220
-                }else{
220
+                } else{
221 221
                     $sslBuilder = Cassandra::ssl()->withVerifyFlags(Cassandra::VERIFY_NONE);
222 222
                 }
223 223
 
Please login to merge, or discard this patch.
src/phpFastCache/CacheManager.php 1 patch
Indentation   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -57,18 +57,18 @@  discard block
 block discarded – undo
57 57
      * @var ExtendedCacheItemPoolInterface[]
58 58
      */
59 59
     protected static $config = [
60
-      'itemDetailedDate' => false,// Specify if the item must provide detailed creation/modification dates
61
-      'autoTmpFallback' => false,// Automatically attempt to fallback to temporary directory if the cache fails to write on the specified directory
62
-      'secureFileManipulation' => false,// Provide a secure file manipulation mechanism, on intensive usage the performance can be affected.
63
-      'ignoreSymfonyNotice' => false,// Ignore Symfony notice for Symfony project which do not makes use of PhpFastCache's Symfony Bundle
64
-      'defaultTtl' => 900,// Default time-to-live in second
65
-      'securityKey' => 'auto',// The securityKey that will be used to create sub-directory
66
-      'htaccess' => true,// Auto-generate .htaccess if tit is missing
67
-      'default_chmod' => 0777, // 0777 recommended
68
-      'path' => '',// if not set will be the value of sys_get_temp_dir()
69
-      'fallback' => false, //Fall back when old driver is not support
70
-      'limited_memory_each_object' => 4096, // maximum size (bytes) of object store in memory
71
-      'compress_data' => false, // compress stored data, if the backend supports it
60
+        'itemDetailedDate' => false,// Specify if the item must provide detailed creation/modification dates
61
+        'autoTmpFallback' => false,// Automatically attempt to fallback to temporary directory if the cache fails to write on the specified directory
62
+        'secureFileManipulation' => false,// Provide a secure file manipulation mechanism, on intensive usage the performance can be affected.
63
+        'ignoreSymfonyNotice' => false,// Ignore Symfony notice for Symfony project which do not makes use of PhpFastCache's Symfony Bundle
64
+        'defaultTtl' => 900,// Default time-to-live in second
65
+        'securityKey' => 'auto',// The securityKey that will be used to create sub-directory
66
+        'htaccess' => true,// Auto-generate .htaccess if tit is missing
67
+        'default_chmod' => 0777, // 0777 recommended
68
+        'path' => '',// if not set will be the value of sys_get_temp_dir()
69
+        'fallback' => false, //Fall back when old driver is not support
70
+        'limited_memory_each_object' => 4096, // maximum size (bytes) of object store in memory
71
+        'compress_data' => false, // compress stored data, if the backend supports it
72 72
     ];
73 73
 
74 74
     /**
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
                 }
123 123
             }
124 124
         } else if(++$badPracticeOmeter[$driver] >= 5){
125
-           trigger_error('[' . $driver . '] Calling many times CacheManager::getInstance() for already instanced drivers is a bad practice and have a significant impact on performances.
125
+            trigger_error('[' . $driver . '] Calling many times CacheManager::getInstance() for already instanced drivers is a bad practice and have a significant impact on performances.
126 126
            See https://github.com/PHPSocialNetwork/phpfastcache/wiki/[V5]-Why-calling-getInstance%28%29-each-time-is-a-bad-practice-%3F');
127 127
         }
128 128
 
@@ -249,23 +249,23 @@  discard block
 block discarded – undo
249 249
     public static function getStaticSystemDrivers()
250 250
     {
251 251
         return [
252
-          'Apc',
253
-          'Apcu',
254
-          'Cassandra',
255
-          'Couchbase',
256
-          'Devnull',
257
-          'Files',
258
-          'Leveldb',
259
-          'Memcache',
260
-          'Memcached',
261
-          'Memstatic',
262
-          'Mongodb',
263
-          'Predis',
264
-          'Redis',
265
-          'Ssdb',
266
-          'Sqlite',
267
-          'Wincache',
268
-          'Xcache',
252
+            'Apc',
253
+            'Apcu',
254
+            'Cassandra',
255
+            'Couchbase',
256
+            'Devnull',
257
+            'Files',
258
+            'Leveldb',
259
+            'Memcache',
260
+            'Memcached',
261
+            'Memstatic',
262
+            'Mongodb',
263
+            'Predis',
264
+            'Redis',
265
+            'Ssdb',
266
+            'Sqlite',
267
+            'Wincache',
268
+            'Xcache',
269 269
         ];
270 270
     }
271 271
 
Please login to merge, or discard this patch.