如何将 Zend Cache 与 SimpleXML 对象一起使用?

发布于 2024-08-24 02:54:15 字数 477 浏览 3 评论 0原文

我正在尝试使用 Zend_Service_Twitter 缓存 Twitter 提要的用户时间线,它以 SimpleXML 对象的形式返回其结果。不幸的是,常规序列化函数(Zend Cache 使用的)不能很好地处理 SimpleXMl 对象。我发现这个 http://www.mail-archive .com/[电子邮件受保护]/msg18133.html

因此,看起来我需要为 Zend Cache 创建某种自定义前端,以便能够更改所使用的序列化函数。有人已经这样做过或者可以指出我从哪里开始吗?

I'm trying to cache the user timeline of a Twitter feed using Zend_Service_Twitter which returns its results as a SimpleXML object. Unfortunately the regular serialize functions (which Zend Cache uses) don't play nice with SimpleXMl objects. I found this http://www.mail-archive.com/[email protected]/msg18133.html.

So it looks like I'll need to create some kind of custom frontend for Zend Cache to be able to change the serialize function used. Anybody ever done this already or can point me where to look to start?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

童话里做英雄 2024-08-31 02:54:15

我没有尝试缓存 SimpleXML 对象,而是选择循环遍历返回的 Twitter 帖子并将该数据保存为字符串。然后我将该字符串保存到缓存中。对我有用!

Instead of trying to cache the SimpleXML object, I chose to loop through Twitter posts returned and save that data as a string. I then save that string to the cache. Works for me!

虫児飞 2024-08-31 02:54:15

或者您可以调用 asXML() 函数:

$simpleXml = @simplexml_load_file($xml_url);
$cache->save($simpleXml->asXML(), 'name_of_cache');

定义和用法

asXML() 函数从 SimpleXMLElement 返回 XML 文档
对象,作为字符串。
失败时此函数返回 FALSE。

Or you can call asXML() function:

$simpleXml = @simplexml_load_file($xml_url);
$cache->save($simpleXml->asXML(), 'name_of_cache');

Definition and Usage

The asXML() function returns the XML document, from a SimpleXMLElement
object, as a string.
This function returns FALSE on failure.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文