File tree Expand file tree Collapse file tree 2 files changed +29
-4
lines changed Expand file tree Collapse file tree 2 files changed +29
-4
lines changed Original file line number Diff line number Diff line change @@ -247,12 +247,13 @@ public function restoreLock($name, $owner)
247247 */
248248 public function forget ($ key )
249249 {
250- if ($ this ->files ->exists ($ file = $ this ->path ("illuminate:cache:flexible:created: {$ key }" ))) {
251- $ this ->files ->delete ($ file );
252- }
253250
254251 if ($ this ->files ->exists ($ file = $ this ->path ($ key ))) {
255- return $ this ->files ->delete ($ file );
252+ return tap ($ this ->files ->delete ($ file ), function ($ forgotten ) use ($ key ) {
253+ if ($ forgotten && $ this ->files ->exists ($ file = $ this ->path ("illuminate:cache:flexible:created: {$ key }" ))) {
254+ $ this ->files ->delete ($ file );
255+ }
256+ });
256257 }
257258
258259 return false ;
Original file line number Diff line number Diff line change @@ -350,6 +350,30 @@ public function testItHandlesForgettingNonFlexibleKeys()
350350 $ this ->assertFileDoesNotExist ($ flexiblePath );
351351 }
352352
353+ public function itOnlyForgetsFlexibleKeysIfParentIsForgotten ()
354+ {
355+ $ store = new FileStore (new Filesystem , __DIR__ );
356+
357+ $ key = Str::random ();
358+ $ path = $ store ->path ($ key );
359+ $ flexiblePath = "illuminate:cache:flexible:created: {$ key }" ;
360+
361+ touch ($ flexiblePath );
362+
363+ $ this ->assertFileDoesNotExist ($ path );
364+ $ this ->assertFileExists ($ flexiblePath );
365+
366+ $ store ->forget ($ key );
367+
368+ $ this ->assertFileDoesNotExist ($ path );
369+ $ this ->assertFileExists ($ flexiblePath );
370+
371+ $ store ->put ($ key , 'value ' , 5 );
372+
373+ $ this ->assertFileDoesNotExist ($ path );
374+ $ this ->assertFileDoesNotExist ($ flexiblePath );
375+ }
376+
353377 protected function mockFilesystem ()
354378 {
355379 return $ this ->createMock (Filesystem::class);
You can’t perform that action at this time.
0 commit comments