File tree Expand file tree Collapse file tree 2 files changed +39
-0
lines changed
Expand file tree Collapse file tree 2 files changed +39
-0
lines changed Original file line number Diff line number Diff line change @@ -124,4 +124,19 @@ public function deleteMultiple($keys)
124124 {
125125 return $ this ->driver ->deleteMultiple ($ keys );
126126 }
127+
128+ /**
129+ * Create or rebuid the data schema.
130+ * This method is avaialbe for Mysql and Sqlite drivers.
131+ *
132+ * @return bool
133+ */
134+ public function rebuild (): bool
135+ {
136+ if (method_exists ($ this ->driver , 'rebuild ' )) {
137+ return $ this ->driver ->rebuild ();
138+ }
139+
140+ return false ;
141+ }
127142}
Original file line number Diff line number Diff line change @@ -131,4 +131,28 @@ public function testIsExpired()
131131 $ result = $ method ->invokeArgs ($ cache , [$ dateInterval , $ time ]);
132132 $ this ->assertFalse ($ result );
133133 }
134+
135+ public function testRebuildShouldReturnTrue ()
136+ {
137+ $ driver = new Cache ('mysql ' , [
138+ 'dbname ' => 'shieldon_unittest ' ,
139+ 'user ' => 'shieldon ' ,
140+ 'pass ' => 'taiwan ' ,
141+ ]);
142+
143+ $ this ->assertTrue ($ driver ->rebuild ());
144+
145+ $ driver = new Cache ('sqlite ' , [
146+ 'storage ' => create_tmp_directory ()
147+ ]);
148+
149+ $ this ->assertTrue ($ driver ->rebuild ());
150+ }
151+
152+ public function testRebuildShouldReturnFalse ()
153+ {
154+ $ driver = new Cache ('apcu ' );
155+
156+ $ this ->assertFalse ($ driver ->rebuild ());
157+ }
134158}
You can’t perform that action at this time.
0 commit comments