Skip to content

Commit

Permalink
Also fix batch cache flush in older Laravel versions
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickbrouwers committed Feb 19, 2024
1 parent 6689506 commit 6e04801
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/Cache/MemoryCacheDeprecated.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Maatwebsite\Excel\Cache;

use PhpOffice\PhpSpreadsheet\Cell\Cell;
use Psr\SimpleCache\CacheInterface;

class MemoryCacheDeprecated implements CacheInterface
Expand All @@ -17,7 +18,7 @@ class MemoryCacheDeprecated implements CacheInterface
protected $cache = [];

/**
* @param int|null $memoryLimit
* @param int|null $memoryLimit
*/
public function __construct(int $memoryLimit = null)
{
Expand Down Expand Up @@ -131,6 +132,12 @@ public function flush(): array
{
$memory = $this->cache;

foreach ($memory as $cell) {
if ($cell instanceof Cell) {
$cell->detach();
}
}

$this->clear();

return $memory;
Expand Down

0 comments on commit 6e04801

Please sign in to comment.