Skip to content

Commit ad56616

Browse files
author
MarkBaker
committed
Reduce size of Unique ID Prefix used for the Cell Collection when "in memory" (reduces the per-cell memory overhead, while still retaining a unique prefix to ensure no clash between worksheet collections).
External cache (where multiple threads may be accessing the same cache with different workeets) still uses the same length and entropy in the prefix as before
1 parent 9275d0c commit ad56616

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/PhpSpreadsheet/Collection/Cells.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use PhpOffice\PhpSpreadsheet\Cell\Cell;
77
use PhpOffice\PhpSpreadsheet\Cell\Coordinate;
88
use PhpOffice\PhpSpreadsheet\Exception as PhpSpreadsheetException;
9+
use PhpOffice\PhpSpreadsheet\Settings;
910
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
1011
use Psr\SimpleCache\CacheInterface;
1112

@@ -298,7 +299,9 @@ public function getHighestRow($column = null)
298299
*/
299300
private function getUniqueID()
300301
{
301-
return uniqid('phpspreadsheet.', true) . '.';
302+
return Settings::getCache() instanceof Memory
303+
? random_bytes(7) . ':'
304+
: uniqid('phpspreadsheet.', true) . '.';
302305
}
303306

304307
/**

0 commit comments

Comments
 (0)