This may be more efficient. 1. First, Check memcache , if hit, done. 2. If not, do a url fetch. If the return has a 'Last-Modified' header, cache it in memcache. done
-----邮件原件----- 发件人: google-appengine@googlegroups.com [mailto:google-appeng...@googlegroups.com] 代表 Bennomatic 发送时间: 2009年5月26日 0:49 收件人: Google App Engine 主题: [google-appengine] Re: urlfetch... Implementing my own cache? Memcache? Hi Jordisan, I'm working on something very similar, and yes, I do use both memcache and the datastore, to ensure that the cached data lasts as long as I want it to. Memcache, IIUC, is not guaranteed to hold onto your data for as long as you specify. So my code looks like this: on request for data: - Check memcache to see if I have it stored (the identifier is the URL path). This way, oft-requested files are served most quickly. - If not, check the datastore. This way, I don't have to hit the originating site for any non-updated data. - If not, do a URL fetch and grab it, caching it in memcache and datastore. For my purposes, I don't store posts--since they're usually dynamic CGI script requests on the sites I'm using it with, and I don't cache gets that have query strings. Eventually, I'm going to build a management app that will allow me to specify cache time, purge stored data manually, etc., but right now it's set up as described above. -Ben On May 25, 2:49 am, jordisan <ram...@gmail.com> wrote: > Hi. > I'm developing an application which connects to external APIs > (delicious) via URLFETCH. Currently every request to my application > causes one (or more) calls to that external APIs. > > I want to implement some kind of INTERMEDIATE CACHE BETWEEN MY APP AND > EXTERNAL APIS to speed up response time and avoid bothering too much > external systems. > > I'm not sure MEMCACHE is a good solution since every external call may > be different depending on the request (typically it will be different > for every user). > > Is there any easy-to-use solution for implementing that cache? Should > I implement my own system? Is it a good idea to use Memcache? > > Thanks :) > __ > jordisanhttp://jordisan.net --~--~---------~--~----~------------~-------~--~----~ 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-appengine@googlegroups.com To unsubscribe from this group, send email to google-appengine+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/google-appengine?hl=en -~----------~----~----~----~------~----~------~--~---