I have been playing around with the Old RSS module, and have it working, but would like to cache the XML that is returned from the module for a certain amount of time, and getting it from the cache rather than regenrating it each time.
The code I added is as follows:
$cacheKey = "Rss::renderImmediate(".$entityType.",".$itemId.")";
if (GalleryDataCache::containsKey($cacheKey)) {
$xml = GalleryDataCache::get($cacheKey);
}
// If the data wasnt in the cache, get it.
if (empty($xml)) {
...
Existing Generate RSS XML Code In file Rss.inc
...
list ($ret, $xml) = $template->fetch(dirname(__FILE__) . '/templates/Rss.tpl');
if ($ret->isError()) {
return $ret->wrap(__FILE__, __LINE__);
}
// Cache XML here
GalleryDataCache::put($cacheKey,$xml);
}
Unfortunately the XML is not in the cache on the next call.
Am I using the cache in the wrong way??
Any help greatly appreciated.
Reuven.
Posts: 32509
why don't you use the new rss module? afaik it's quite stable and feature rich... (gallery-contrib).
@caching:
GalleryDataCache has 2 levels of caching:
1. memory cache that is only used during each request. e.g. such that you don't do the same SQL queries in the same request.
2. disk cache that is used to cache information for multiple HTTP requests.
what you use is the memory caching, but you actually want to use the disk caching (putToDisk, ...). there are plenty of examples, just grep for the file caching methods in modules/core/classes/helpers/
Posts: 22
Thanks for the reply Valiant...makes perfect sense.
Are there any docs for the new RSS module. I actually got it from the CVS, but it seemed to have problems, and was not working too well.
Also I reverse engineered the URL to get the feed, as there were no docs, so its possible that I screwed it up.
What is the feed supposed to look like?
Thanks,
Reuven
Posts: 32509
never tried the new rss module, sorry. well i tried it for 30 seconds to take a look at it, that's it.
as far as i remember, you go to a options page, define exactly what you want by ticking a few checkboxes and then click on generate url or something like that. then, use the generated url as rss feed url.
if there are no docs included, there are no docs i guess.