APC缓存SimpleXMLElement对象的数组

时间:2013-02-20 12:33:07

标签: php arrays simplexml apc

我在缓存SimpleXMLElement对象数组时遇到了困难。这是失败的apc_store行,我不知道为什么。

程序终止于此行,这很奇怪,因为我在其他地方使用过它 - 将数组包装在ArrayObject中并将其存储在缓存中。

我的代码摘录如下:

    $feed = /* some url */
    $xml = simplexml_load_file($feed);
    $items = $xml -> xpath('/rss//item');

    foreach($items as $item){
        $item -> addChild('myTag1', "My Tag 1");
        $item -> addChild('myTag2', "My Tag 2");
    }

    apc_store($feed, new ArrayObject($items), 60);

我认为我的日志文件没有正常工作,这是最后一个条目,以防它有所帮助,但我认为它与SSL有关并且没有帮助:

[Wed Feb 20 12:21:51 2013] [notice] caught SIGTERM, shutting down
Attempt to free unreferenced scalar: SV 0x7fe7805e2130, Perl interpreter: 0x7fe7805ea4f0 during global destruction.
[Wed Feb 20 12:21:54 2013] [notice] suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
[Wed Feb 20 12:21:54 2013] [notice] SSL FIPS mode disabled
Attempt to free unreferenced scalar: SV 0x7f94bfa75ec0, Perl interpreter: 0x7f94bfa56550 during global destruction.
[Wed Feb 20 12:21:57 2013] [notice] Digest: generating secret for digest authentication ...
[Wed Feb 20 12:21:57 2013] [notice] Digest: done
[Wed Feb 20 12:21:59 2013] [notice] mod_python: Creating 4 session mutexes based on 256 max processes and 0 max threads.
[Wed Feb 20 12:21:59 2013] [notice] mod_python: using mutex_directory /tmp 
[Wed Feb 20 12:21:59 2013] [notice] SSL FIPS mode disabled
[Wed Feb 20 12:21:59 2013] [notice] Apache/2.2.22 (Unix) DAV/2 PHP/5.4.10 mod_python/3.3.1    Python/2.7.3 mod_ssl/2.2.22 OpenSSL/1.0.0j-fips mod_perl/2.0.5 Perl/v5.14.3 configured -- resuming   normal operations

感谢您的帮助。

1 个答案:

答案 0 :(得分:0)

在上面的示例中,$ feed不是网址的字符串表示形式;它是一个数组,其第一个元素是url的字符串表示形式。另外,我使用名称空间,因此ArrayObject需要一个斜杠前缀。