PHP 和请求之间共享资源 [英] PHP and sharing resources between requests

查看:49
本文介绍了PHP 和请求之间共享资源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一种在请求之间共享 PHP 资源的方法.首先,我想分享解析的XML.我有一些以只读模式使用的大型 XML,目前我必须为每个 HTTP 请求加载和解析它.

I'm looking for a way to share PHP resources between requests. First of all, I want to share parsed XML. I have some large XML that I use in readonly mode, and currently I have to load and parse it for each HTTP request.

我读过这个:http://php.net/manual/en/function.shm-put-var.php 和其他共享内存 API 文档,我知道没有直接的方法将资源存储在共享内存中.这就是我在这里问的原因.

I've read this: http://php.net/manual/en/function.shm-put-var.php and the other shared memory API documentation, and I know that there is no straight way to store resources in shared memory. That's why I ask here.

所以,我有 XML,我在只读模式下使用它(执行 XPath 请求),这个 XML 很大,我正在寻找某种方法来消除为每个 HTTP 请求加载和解析它的需要.对此有何想法或建议?

So, I have XML, I use it in readonly mode (performing XPath-requests), this XML is large, and I'm looking for some way to eliminate the need of loading and parsing it for each HTTP request. Any ideas or advices about this?

谢谢.

推荐答案

如果您的服务器上启用了 APC,请查看 apc_store

If you have APC enabled on your server, take a look at apc_store

http://php.net/manual/de/function.apc-store.php

与 PHP 中的许多其他机制不同,变量存储使用apc_store() 将在请求之间持续存在(直到值被删除从缓存中)

Unlike many other mechanisms in PHP, variables stored using apc_store() will persist between requests (until the value is removed from the cache)

这篇关于PHP 和请求之间共享资源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆