SimplePie分页/缓存 [英] SimplePie Pagination / Cache

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

问题描述

我试图了解Linux上SimplePie的缓存功能.它从不告诉我们为RSS提要创建一个单独的mySql数据库,因此我猜测所有缓存都在本地完成. (在/httpdocs/目录中?)

I'm trying to understand the cache'ing features of SimplePie on linux. It never tells us to create a separate mySql database for the RSS feeds, so i'm guessing all the cache is done locally. (in the /httpdocs/ directories ? )

我无法弄清楚SimplePie导入文章后如何存储它们(使用linux指令上的默认安装)以及这些文章在数据库中存储了多长时间.

I can't figure out how SimplePie stores it's articles once their imported...(using default install on linux instructions) and how long these articles are stored in the DB.

此问题主要与SimplePie有关,该网站具有在其网站上指定的简单分页设置-

This issue is mostly regarding SimplePie with a simple pagination setup as specified on their site here -

http://simplepie.org/wiki/tutorial/how_to_do_item_paging

但是,事实是,在相互覆盖之前,它只能保留一定数量的项目(文章).

But the thing is, it only keeps a certain amount of items (articles) before they overwrite each other.

例如,我在这里有一个基本的SimplePie小页面设置-

For example, I have a basic little SimplePie page setup here -

http://www.oil-gas-prices.com/

在底部,它总是在76左右截止.(显示76中的1-10)

at the bottom, it always cuts off at around 76. (showing 1 - 10 of 76)

我想指定一个1000.这样它就可以在那附近切断.

I want to specify a 1000. So that it cuts off around there.

以下调整这些特定值中的任何一个都不会增加索引/缓存项的总数:

Adjusting any of these specific values below does nothing to increase the overall amount of indexed / cached items :

// Set our paging values
$start = (isset($_GET['start']) && !empty($_GET['start'])) ? $_GET['start'] : 0; // Where do we start?
$length = (isset($_GET['length']) && !empty($_GET['length'])) ? $_GET['length'] : 5; // How many per page?
$max = $feed->get_item_quantity(); // Where do we end?

我的首要任务是在缓存中存储更多内容,而其他文章不会覆盖它们,从而减少了已存储项目的数量.

My main priority is to store more in the cache, without other articles overwriting them, thus lowering the number of stored items.

我已经在Linux上安装了最新版本的SimplePie.没有wordpress扩展名或其他任何内容.

I've got the latest version of SimplePie installed on the linux. No wordpress extensions or anything.

非常感谢您的帮助.如今,很难找到合法的SimplePie帮助,

I appreciate any help very much . It's so hard to find legit SimplePie help these days,

推荐答案

默认情况下,它会将缓存的文章存储在/cache目录中,尽管它们的文档指出:"SimplePie包括可与基于文件的文件一起使用的缓存系统.缓存,数据库缓存或支持Memcache的缓存系统.".默认的缓存持续时间为一小时.但是,您可以使用set_cache_duration函数覆盖它.确保您已将高速缓存文件夹权限设置为至少755.您可能需要将其增加到775或777(但请尽可能避免这样做).

It stores the cached articles in the /cache directory by default, although their documentation states: "SimplePie includes a caching system which can be used with a file-based cache, database cache or a Memcache-backed cache system.". The default cache duration is one hour. You can override it however with the set_cache_duration function. Make sure you have the cache folder permissions set to at least 755. You may need to increase it to 775 or 777 (but avoid this if at all possible).

至于项目数量的限制,您是在设置Feed的最大数量还是每个Feed的最大数量?对于我的实现,我将其限制为每个Feed 25和3,并且效果很好.我不知道是否有默认最大值,但是可能会有,您可能必须手动覆盖它.例如,我的网站上有以下PHP代码:

As far as the limit on the number of items, are you setting the maximum number of feeds, or the maximum items per feed? For my implementation I limited it to 25 and 3 per feed and it works well. I don't know if there's a default maximum, but there may be and you may have to manually override it. For instance, I have this PHP code on my site:

$max_items_total = 25;     // This sets the maximum number of blogroll items to display
$max_items_per_feed = 3;   // this sets the maximum number of items from each feed to display

$feed = new SimplePie();
$feed->set_feed_url($feed_ary);

// limit the number of items
$feed->set_item_limit($max_items_per_feed);
$feed->enable_cache(true);  // on by default, but I want to be sure
$feed->set_cache_duration(86400);  // set cache duration to 24 hours

foreach ($feed->get_items(0, $max_items_total) as $key=>$item) {
   ...
}

for循环为我获取项目1到25.您可以使用类似的方法进行分页.

The for loop gets items 1 through 25 for me. You could use a similar method for pagination.

我在缓存方面也遇到了问题,也希望从其他人那里获得更多信息.

I'm also having issues with caching, and would also appreciate some more info from others.

这篇关于SimplePie分页/缓存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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