PHP中的初学者数据缓存 [英] Beginner data caching in PHP

查看:59
本文介绍了PHP中的初学者数据缓存的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用simpleXML来检查Twitter XML文件的XML结果,但是我完全不知道如何使用PHP缓存结果. 这篇文章似乎有帮助,但我遇到过内存缓存(和内存缓存.来吧,命名者.),我也不知道该怎么办.

I'm using simpleXML to go through the XML results of a Twitter XML file, but I'm completely lost as to caching the results with PHP. This article seems to be of some help, but I've come across memcache (and memcached. C'mon, namers.) as well, and I have no idea what to do.

我正在使用它:

$sxml = simplexml_load_file(
    'http://api.twitter.com/1/qworky/lists/qworkyteam/statuses.xml');

foreach($sxml->status as $status){
    $name = $status->user->name;
    $image = $status->user->profile_image_url;
    $update = $status->text;
    $url = "http://twitter.com/" . $status->user->screen_name;
}

仅将Twitter列表的XML数据存储到可用变量中.但是,正确的做法是什么?创建一个缓存文件,并且仅在该缓存文件的时间超过十分钟时才运行此PHP块,否则提供缓存的变量吗?如何在缓存文件和DOM之间来回传递缓存变量?哎呀,缓存文件有什么样的扩展名和文件名?

to simply store the XML data of a Twitter list into usable variables. But what's the right thing to do? Create a cache file and only run this block of PHP if the cache file is older than ten minutes, otherwise serve up the cached variables? How do I pass the cached variables back-and-forth between the cached file and the DOM? Heck, what kind of extension and filename does a cache file have?

非常感谢您在这里可以为我指明一个健康的方向.

Thanks so much for any way you can point me in a healthy direction here.

推荐答案

约书亚(Joshua)看这篇关于简单的PHP缓存的文章,您可以相对轻松地完全按照您的描述进行操作(是的,这可能是最明智的选择).

Joshua take a look at this article about simple PHP caching, you can do exactly as you've described with relative ease (and yes is probably the most sensible way to go).

这篇关于PHP中的初学者数据缓存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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