惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

酷 壳 – CoolShell
酷 壳 – CoolShell
H
Hacker News: Front Page
P
Palo Alto Networks Blog
T
ThreatConnect
Apple Machine Learning Research
Apple Machine Learning Research
博客园_首页
T
True Tiger Recordings
P
Privacy & Cybersecurity Law Blog
B
Blog
IT之家
IT之家
Last Week in AI
Last Week in AI
F
Full Disclosure
Hacker News: Ask HN
Hacker News: Ask HN
C
Comments on: Blog
Microsoft Azure Blog
Microsoft Azure Blog
C
Cybersecurity and Infrastructure Security Agency CISA
Microsoft Security Blog
Microsoft Security Blog
博客园 - 【当耐特】
N
News and Events Feed by Topic
NISL@THU
NISL@THU
腾讯CDC
雷峰网
雷峰网
Security Latest
Security Latest
李成银的技术随笔
M
Microsoft Research Blog - Microsoft Research
L
LangChain Blog
L
Lohrmann on Cybersecurity
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
C
Check Point Blog
Y
Y Combinator Blog
Recent Announcements
Recent Announcements
博客园 - Franky
N
News | PayPal Newsroom
V
V2EX
A
About on SuperTechFans
The Register - Security
The Register - Security
月光博客
月光博客
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Google Online Security Blog
Google Online Security Blog
MyScale Blog
MyScale Blog
Cisco Talos Blog
Cisco Talos Blog
Vercel News
Vercel News
WordPress大学
WordPress大学
C
Cyber Attacks, Cyber Crime and Cyber Security
The Hacker News
The Hacker News
IntelliJ IDEA : IntelliJ IDEA – the Leading IDE for Professional Development in Java and Kotlin | The JetBrains Blog
IntelliJ IDEA : IntelliJ IDEA – the Leading IDE for Professional Development in Java and Kotlin | The JetBrains Blog
爱范儿
爱范儿
A
Arctic Wolf
L
LINUX DO - 最新话题
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More

博客园 - myx

安装gitlab管理自己的代码 升级Tornado到4后weibo oauth登录不了 SQL Server 无日志文件附加数据库 用monit监控系统关键进程 Failed to read auto-increment value from storage engine错误的处理方法 今天测试了一下 sqlalchemy 性能 PIL The _imaging C module is not installed tcpdf慢及常用的一些方法及问题 Python获取WebService CodeIgniter出现Disallowed Key Characters的问题 CodeIgniter链接ms sql 如果数据库名称有点号连接出错 用python写windows服务 CodeIgniter链接ms sql 的过程windows 2008 关于NTLM认证的.NET,php,python登录 DotNetOpenAuth的Facebook登录,获取头像与基本资料 php里的html内容切取 js生成新加坡的NRIC号码 Sina站内应用的登录 PowerDesigner 链接MySql 用ODBC链接不上的问题
phpExcel大数据量情况下内存溢出解决
myx · 2013-05-20 · via 博客园 - myx

版本:1.7.6+

在不进行特殊设置的情况下,phpExcel将读取的单元格信息保存在内存中,我们可以通过

PHPExcel_Settings::setCacheStorageMethod()

来设置不同的缓存方式,已达到降低内存消耗的目的!

1、将单元格数据序列化后保存在内存中

PHPExcel_CachedObjectStorageFactory::cache_in_memory_serialized; 

2、将单元格序列化后再进行Gzip压缩,然后保存在内存中

PHPExcel_CachedObjectStorageFactory::cache_in_memory_gzip; 

3、缓存在临时的磁盘文件中,速度可能会慢一些

PHPExcel_CachedObjectStorageFactory::cache_to_discISAM;

4、保存在php://temp

PHPExcel_CachedObjectStorageFactory::cache_to_phpTemp; 

5、保存在memcache中

PHPExcel_CachedObjectStorageFactory::cache_to_memcache

        $cacheMethod = PHPExcel_CachedObjectStorageFactory::cache_to_memcache;  
        $cacheSettings = array( 'memcacheServer'  => 'localhost',  
                        'memcachePort'    => 11211,  
                        'cacheTime'       => 600  
                      );  
        PHPExcel_Settings::setCacheStorageMethod($cacheMethod, $cacheSettings);

注意是加在new PHPExcel() 前面:如下

1 require_once APPPATH .'third_party/PHPExcel/PHPExcel.php';
2         
3         $cacheMethod = PHPExcel_CachedObjectStorageFactory::cache_to_phpTemp;
4         $cacheSettings = array('memoryCacheSize'=>'16MB');
5         PHPExcel_Settings::setCacheStorageMethod($cacheMethod, $cacheSettings);
6         
7         $objPHPExcel = new PHPExcel();