On Fri, Aug 14, 2009 at 8:33 AM, a b<[email protected]> wrote:
>
> I did something about memcache... Here is my code.. But when i call
> the rss from memcache the content is empty and i see an empty page..
> Have u got any idea about it?
>
Hi,
you never perform any get on memcache, your arrays $aa, $bb and $cc
are never populated.
Ludo
> Thanks..
>
> <?php
> require_once 'simplepie.php';
> $feed = new SimplePie();
> $feed->set_feed_url('http://blablabla.com/rss');
> $feed->set_output_encoding('
> ISO-8859-9');
> $feed->init();
> $feed->handle_content_type();
>
> $memcache = new Memcache;
> $memcache -> connect('localhost', 11211);
>
> $aa = array();
> $bb = array();
> $cc = array();
>
> if($feed->error()) {
> echo '<strong>Error!</strong>: '.$feed->error();
> exit();
> }
> $limit = $feed->get_item_quantity(5);
> printf("<h1>%s</h1>", $feed->get_title());
>
> if ($memcache){
> for($i=0; $i<$limit; ++$i)
>
> printf("<h4> <a href=\"%s\">%s</a> </h4>", $bb[i], $aa[i]);
> echo "<br/><br/>";
> printf("<p>%s</p>", $cc[i]);
>
> } else {
> for($i=0; $i<$limit; ++$i)
> {
> $item = $feed->get_item($i);
>
> printf("<h4> <a href=\"%s\">%s</a> </h4>", $item->get_permalink
> (), $item->get_title());
> printf("<p>%s</p>", $item->get_description());
>
> $a = $item->get_title();
> $b = $item->get_permalink();
> $c = $item->get_description();
> $memcache->set('title', $a ,false , 10);
> $aa[i] = $memcache->get('title');
> $memcache->set('link', $b , false, 10);
> $bb[i] = $memcache->get('link');
> $memcache->set('description', $c,false, 10);
> $cc[i] = $memcache->get('description');
>
> printf("<p><small>%s</small></p>", $item->get_date('d.m.Y
> H:i'));
> print '<hr/>';
> }
> }
>
> ?>