Memcache problem with Python feedparser !!

49 views
Skip to first unread message

Ayan

unread,
Dec 11, 2011, 2:43:24 AM12/11/11
to Google App Engine
Dear Friends,

I am using Python Feedparser (http://code.google.com/p/feedparser/) to
read some RSS feed for my application.

I want to Cache the RSS feed for 1 hour. No need to do the UrlFetch
every single time.

For that, I wrote this CODE -
--------------------------------------------------------
def get_data(NewsID):
data=memcache.get(NewsID)
if not data:
data=feedparser.parse('http://mysite.com/feeds/'+NewsID+'/')
if not data:
memcache.add(NewsID, data, 3600)
return data
--------------------------------------------------------
The format of NewID is: ABC1234567890 string format

PROBLEM: It seems, it is not Caching at all !!


Can you please tell me whats wrong ???

Brandon Wirtz

unread,
Dec 11, 2011, 2:59:12 AM12/11/11
to google-a...@googlegroups.com
Probably your instance doesn't live long enough, or your RSS is too big, or
you aren't escaping the XML for the data type you are using.

Oh, and memcache, never going to live for a full hour. Not what it is for.
I give it 25 minutes tops.

Dear Friends,

--
You received this message because you are subscribed to the Google Groups
"Google App Engine" group.
To post to this group, send email to google-a...@googlegroups.com.
To unsubscribe from this group, send email to
google-appengi...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/google-appengine?hl=en.


Simon Knott

unread,
Dec 11, 2011, 4:31:54 AM12/11/11
to google-a...@googlegroups.com
I don't know Python, but isn't your second "if not data" basically saying that if you don't have data, then put it in Memcache - seems to be the wrong way round to me!
Reply all
Reply to author
Forward
0 new messages