Key-Value storage API demo

Here's a snapshot of our first official demo application. It's basically one JavaScript file with few dependencies (jQuery and HMAC-SHA1) that uses the Pageforest API to authenticate an existing user, then store and retrieve data in the Key-Value store. The source code of this version is available here: http://code.google.com/p/pageforest/source/browse/?r=eeeeee#hg/examples/keyvalue (JavaScript application and Django project for the server side on Google App Engine).

Photo

Next, we are going to change the auth mechanism and require that username and password are entered only on a trusted page like https://auth.pageforest.com/ in a separate browser tab. Then the JavaScript app doesn't have to deal with the details of cryptographic authentication, and malicious applications don't have access to user credentials.

Memcache mixin for datastore models

So we made a datastore model mixin that will transparently use memcache. It is available on Google Code under the MIT license, just like the rest of pageforest.com: http://code.google.com/p/pageforest/source/browse/appengine/utils/cacheable.py

To use it, just inherit your model from it:

from google.appengine.ext import db
from utils.mixins import Cacheable

class App(Cacheable):
    name = db.StringProperty()

The interesting part is that it automatically reduces datastore write contention by skipping datastore put if the write rate is consistently high. The App Engine datastore only supports 5 updates per second. So if one entity gets 10 updates per second, the Cacheable mixin makes sure that it's always saved to memcache but the datastore is updated only once every 2 seconds.