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 ? )
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.
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.
For example, I have a basic little SimplePie page setup here -
http://www.oil-gas-prices.com/
at the bottom, it always cuts off at around 76. (showing 1 - 10 of 76)
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.
I've got the latest version of SimplePie installed on the linux. No wordpress extensions or anything.
I appreciate any help very much . It's so hard to find legit SimplePie help these days,
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).
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) {
...
}
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.
来源:https://stackoverflow.com/questions/15737427/simplepie-pagination-cache