Hi!
I have a simple image-server.py with the following code:
import cgi
import logging
from google.appengine.ext import db
from google.appengine.ext import webapp
from google.appengine.ext.webapp.util import run_wsgi_app
from google.appengine.api import memcache
class Image(webapp.RequestHandler):
def get(self):
if self.request.get("key") != "":
key = self.request.get("key")
data = memcache.get(key)
if data is not None:
if data.image:
self.response.headers['Content-Type'] = "image/
png"
#self.response.headers['Cache-Control'] = "public,max-
age=31104000"
self.response.out.write(data.image[0].image)
logging.debug("Served from memcache")
else:
self.response.out.write("No image")
else:
data = db.get(key)
if data.image:
self.response.headers['Content-Type'] = "image/png"
#self.response.headers['Cache-Control'] = "public,max-
age=31104000"
self.response.out.write(data.image[0].image)
logging.debug("Served from datastore")
else:
self.response.out.write("No image")
if not memcache.add(key, data):
logging.debug("Memcached failed!!!!!!!")
else:
self.response.out.write("No image")
application = webapp.WSGIApplication([
('/download', Image)
], debug=True)
def main():
run_wsgi_app(application)
if __name__ == '__main__':
main()
I did a test and served 1000 images after they have all been cached in
memcache.
The Admin Logs show that all requests are "Served from memcache".
However, when I check the Quota Details in the Admin, I noticed that
for every request, not only the quota details for Memcache API Calls,
but Datastore API Calls are also incremented.
Memcache quota displayed 1000 while datastore quota displayed exactly
2000 API calls.
And the ratio is for every 1 memcache API call, 2 datastore API Calls
are called.
I have no idea, why this is so. Please, someone enlighten me.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Google App Engine" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/google-appengine?hl=en
-~----------~----~----~----~------~----~------~--~---