单元格条目A1在缓存中不再存在

时间:2019-03-18 15:26:17

标签: php phpspreadsheet phpoffice apcu

我将PhpOffice \ PhpSpreadsheet与Apcu缓存一起使用,并且出现此错误
错误:单元格条目A1在缓存中不再存在。这可能意味着缓存已被其他人清除。

$pool = new \Cache\Adapter\Apcu\ApcuCachePool();
$simpleCache = new \Cache\Bridge\SimpleCache\SimpleCacheBridge($pool);

\PhpOffice\PhpSpreadsheet\Settings::setCache($simpleCache);

$objReader = \PhpOffice\PhpSpreadsheet\IOFactory::createReader("Xlsx");
$objReader->setReadDataOnly(true);
$objPHPExcel = $objReader->load(dirname(__FILE__).'/Tmpfile'.$i.'.xlsx');

$objPHPExcel->setActiveSheetIndex(0);

foreach ( $objPHPExcel->getActiveSheet()->getRowIterator() as $row ) {
    if ( $row->getRowIndex() == 1 ){
        $row->getCellIterator();
        $cellIterator = $row->getCellIterator();
        $cellIterator->setIterateOnlyExistingCells(false); // Loop all cells, even if it is not set
        $shop_row = array();
        try {
            foreach ($cellIterator as $key => $cell) { // <<<====== WHERE I got the ERROR
                $key = \PhpOffice\PhpSpreadsheet\Cell\Coordinate::columnIndexFromString($key); ....

我不知道要解决这个问题。
php版本7.1
phpOffice 1.5.2
5.1.17

1 个答案:

答案 0 :(得分:0)

问题来自超出APCu允许的内存值 php.ini> apcu>请更改“ apc.shm_size”的值 例如:

apc.shm_size=1024M