Rob*_*_UK 3 php caching memory-leaks phpexcel
基本上我试图启用单元格缓存由于内存问题(不断耗尽)其相当大的speadsheet.从我在网上看到的细胞缓存是一个很好的方法
从我在网上找到的例子看起来像这样
$oExcel = new PHPExcel();
$cacheMethod = PHPExcel_CachedObjectStorageFactory::cache_to_phpTemp;
$cacheSettings = array( 'memoryCacheSize' => '512MB');
PHPExcel_Settings::setCacheStorageMethod($cacheMethod,$cacheSettings);
Run Code Online (Sandbox Code Playgroud)
上面的问题是我没有设置excel对象的设置?
$oExcel->setCacheStorageMethod($cacheMethod,$cacheSettings); // this returns method not found error
Run Code Online (Sandbox Code Playgroud)
我想我只是初步错了吗?
Mar*_*ker 10
它在开发人员文档的4.2.1节中描述:标题为"Cell Caching"的部分; 并且您需要在实例化或加载PHPExcel对象之前设置单元缓存.
setCacheStorageMethod()不是PHPExcel类的方法,因为您尝试在此行中使用:
$oExcel->setCacheStorageMethod($cacheMethod,$cacheSettings);
Run Code Online (Sandbox Code Playgroud)
使用
$cacheMethod = PHPExcel_CachedObjectStorageFactory::cache_to_phpTemp;
$cacheSettings = array( 'memoryCacheSize' => '512MB');
PHPExcel_Settings::setCacheStorageMethod($cacheMethod,$cacheSettings);
$oExcel = new PHPExcel();
Run Code Online (Sandbox Code Playgroud)
并且新的PHPExcel对象将自动使用配置的缓存设置(即phptemp)