@@ -86,9 +86,9 @@ public function initIndexing(PDO $db)
8686
8787 // delete everything before reset indexing
8888 $ dir = opendir ($ this ->path );
89- while ($ file = readdir ($ dir )) {
90- if ($ file != ". " && $ file!= ".. " && $ file != "indexing " && $ file!= "dbfastcache " ) {
91- unlink ($ this ->path . "/ " . $ file );
89+ while ($ file = readdir ($ dir )) {
90+ if ($ file != ". " && $ file != ".. " && $ file != "indexing " && $ file != "dbfastcache " ) {
91+ unlink ($ this ->path . "/ " . $ file );
9292 }
9393 }
9494
@@ -109,7 +109,7 @@ public function indexing($keyword)
109109 {
110110 if ($ this ->indexing == null ) {
111111 $ createTable = false ;
112- if (!file_exists ($ this ->path . "/indexing " )) {
112+ if (!file_exists ($ this ->path . "/indexing " )) {
113113 $ createTable = true ;
114114 }
115115
@@ -136,8 +136,8 @@ public function indexing($keyword)
136136
137137 // check file size
138138
139- $ size = file_exists ($ this ->path . "/db " . $ db ) ? filesize ($ this ->path . "/db " . $ db ) : 1 ;
140- $ size = round ($ size / 1024 / 1024 ,1 );
139+ $ size = file_exists ($ this ->path . "/db " . $ db ) ? filesize ($ this ->path . "/db " . $ db ) : 1 ;
140+ $ size = round ($ size / 1024 / 1024 , 1 );
141141
142142
143143 if ($ size > $ this ->max_size ) {
@@ -177,18 +177,18 @@ public function indexing($keyword)
177177 */
178178 public function db ($ keyword , $ reset = false )
179179 {
180- /*
180+ /**
181181 * Default is fastcache
182182 */
183183 $ instant = $ this ->indexing ($ keyword );
184184
185- /*
185+ /**
186186 * init instant
187187 */
188188 if (!isset ($ this ->instant [ $ instant ])) {
189189 // check DB Files ready or not
190190 $ createTable = false ;
191- if (!file_exists ($ this ->path . "/db " . $ instant ) || $ reset == true ) {
191+ if (!file_exists ($ this ->path . "/db " . $ instant ) || $ reset == true ) {
192192 $ createTable = true ;
193193 }
194194 $ PDO = new PDO ("sqlite: " . $ this ->path . "/db " . $ instant );
@@ -233,7 +233,7 @@ public function driver_set(
233233 $ time = 300 ,
234234 $ option = array ()
235235 ) {
236- $ skipExisting = isset ($ option ['skipExisting ' ]) ? $ option ['skipExisting ' ] : false ;
236+ $ skipExisting = isset ($ option [ 'skipExisting ' ]) ? $ option [ 'skipExisting ' ] : false ;
237237 $ toWrite = true ;
238238
239239 // check in cache first
@@ -271,14 +271,9 @@ public function driver_set(
271271 } catch (PDOException $ e ) {
272272 return false ;
273273 }
274-
275274 }
276-
277-
278275 }
279-
280276 return false ;
281-
282277 }
283278
284279 /**
@@ -393,30 +388,29 @@ public function driver_stats($option = array())
393388 $ optimized = 0 ;
394389
395390 $ dir = opendir ($ this ->path );
396- while ($ file = readdir ($ dir )) {
397- if ($ file!= ". " && $ file!= ".. " ) {
398- $ file_path = $ this ->path . "/ " . $ file ;
391+ while ($ file = readdir ($ dir )) {
392+ if ($ file != ". " && $ file != ".. " ) {
393+ $ file_path = $ this ->path . "/ " . $ file ;
399394 $ size = filesize ($ file_path );
400395 $ total = $ total + $ size ;
401396
402- try {
403- $ PDO = new PDO ("sqlite: " .$ file_path );
404- $ PDO ->setAttribute (PDO ::ATTR_ERRMODE ,
405- PDO ::ERRMODE_EXCEPTION );
406-
407- $ stm = $ PDO ->prepare ("DELETE FROM `caching` WHERE `exp` <= :U " );
408- $ stm ->execute (array (
409- ":U " => date ("U " ),
410- ));
397+ try {
398+ $ PDO = new PDO ("sqlite: " . $ file_path );
399+ $ PDO ->setAttribute (PDO ::ATTR_ERRMODE ,
400+ PDO ::ERRMODE_EXCEPTION );
411401
412- $ PDO ->exec ("VACUUM; " );
413- $ size = filesize ($ file_path );
414- $ optimized = $ optimized + $ size ;
415- } catch (PDOException $ e ) {
416- $ size = 0 ;
417- $ optimized = 0 ;
418- }
402+ $ stm = $ PDO ->prepare ("DELETE FROM `caching` WHERE `exp` <= :U " );
403+ $ stm ->execute (array (
404+ ":U " => date ("U " ),
405+ ));
419406
407+ $ PDO ->exec ("VACUUM; " );
408+ $ size = filesize ($ file_path );
409+ $ optimized = $ optimized + $ size ;
410+ } catch (PDOException $ e ) {
411+ $ size = 0 ;
412+ $ optimized = 0 ;
413+ }
420414
421415
422416 }
@@ -438,13 +432,13 @@ public function driver_clean($option = array())
438432
439433 // close connection
440434 $ this ->instant = array ();
441- $ this ->indexing = NULL ;
442-
435+ $ this ->indexing = null ;
436+
443437 // delete everything before reset indexing
444438 $ dir = opendir ($ this ->path );
445- while ($ file = readdir ($ dir )) {
446- if ($ file != ". " && $ file!= ".. " ) {
447- unlink ($ this ->path . "/ " . $ file );
439+ while ($ file = readdir ($ dir )) {
440+ if ($ file != ". " && $ file != ".. " ) {
441+ unlink ($ this ->path . "/ " . $ file );
448442 }
449443 }
450444 }
0 commit comments