P.S. Because of issue 2097 (http://code.google.com/p/googleappengine/issues/detail?id=2097), the write-behind task doesn't work on the development server, so it always defaults to write-through (which is a nice test of the watchdog mechanism). The write-behind task works fine on the production servers.
On Mon, Nov 2, 2009 at 3:12 PM, Vince Bonfanti <[email protected]> wrote: > You might be interested in my CachingDatastoreService class: > > http://code.google.com/p/gaevfs/source/browse/trunk/src/com/newatlanta/appengine/datastore/CachingDatastoreService.java > > It has the following features: > > - Implements the com.google.appengine.api.datastore.DatastoreService, > so it's a plug-in replacement for the standard implementation. > - Automatically caches entities in memcache for datastore reads and writes. > - Has a write-behind option (the default) that queues all datastore > writes as background tasks (except for transactions, which are always > write-through directly to the datastore). > - A watchdog task makes sure the write-behind task is always available. > - If the write-behind task isn't available, defaults to write-through > to insure no loss of data. > - Supports configurable expiration of memcache entities (the default > is no expiration). > > In order to use the CachingDatastoreService, first configure the > write-behind task in web.xml: > > <servlet> > <servlet-name>CachingDatastoreService</servlet-name> > > <servlet-class>com.newatlanta.appengine.datastore.CachingDatastoreService</servlet-class> > </servlet> > <servlet-mapping> > <servlet-name>CachingDatastoreService</servlet-name> > <url-pattern>/_ah/queue/write-behind-task</url-pattern> > </servlet-mapping> > > Then configure the write-behind-task queue in queue.xml (use whatever > rate you want): > > <queue> > <name>write-behind-task</name> > <rate>5/s</rate> > </queue> > > Then replace the following code: > > DatastoreService ds = DatastoreServiceFactory().getDatastoreService(); > > with this code, and then use the DatastoreService methods as you normally > would: > > DatastoreService ds = new CachingDatastoreService(); > > The default CachingDatastoreService constructor enables the > CacheOptions.WRITE_BEHIND option and sets the expiration to "null" (no > expiration). There are additional constructors that allow you to > specify CacheOptions.WRITE_THROUGH and/or specify a memcache > expiration value. > > Vince > > On Mon, Nov 2, 2009 at 2:21 PM, Stakka <[email protected]> wrote: >> >> One feature I see useful for a layer atop the Low-Level API is >> asynchronization. Since you'll never know how much time a Low-Level >> API call will take it should automatically create Tasks for them, >> writes atleast. >> >> >> On Oct 22, 10:37 am, Nacho Coloma <[email protected]> wrote: >>> Hi all, >>> >>> We have been developing a persistence framework for the AppEngine >>> Datastore based on the raw DatastoreService API. For our (simple) >>> persistence case, both JDO and JPA were a bit overkill as we were >>> spending a significant amount of time jumping through hoops to make >>> our application roll, but at the same time the Datastore API was a too >>> low-level solution to be usable. >>> >>> So we reinvented our wheel. In two days. >>> >>> SimpleDS is a light wrapper around the DatastoreService APIs that >>> provide a simple interface for java persistent classes. It does not >>> include fancy stuff or any super features, it's just the >>> DatastoreService ported to a world where Java entities can be >>> persisted directly (using a subset of JPA annotations). This is _not_ >>> a JPA/JDO replacement, and will never be. But we have been using it >>> for some weeks and are quite happy with it. >>> >>> Any kind of feedback from the AppEngine community would be welcome. >>> Before calling the typical "but we already have JPA/JDO!" argument, >>> please notice the following: >>> >>> * There are lots of considerations in a relational database that do >>> not apply to AppEngine. This allows a specific solution to be >>> simplified big time. Just see the depth of your typical stack trace to >>> understand what I am talking about. >>> * Solutions can be designed for specific cases that are common >>> practice in AppEngine but do not apply to a relational database. See, >>> for example, saving entities with a parent instance. >>> * Transactions also behave a bit differently, where a "one size fits >>> all" approach would probably not be the best solution. >>> >>> To better ilustrate with an example, these are some typical tasks >>> performed with SimpleDS: >>> >>> Retrieve instance: >>> FooBar bar = entityManager.get(key); >>> >>> Transform from Google Datastore Entity to java and viceversa: >>> Entity entity = entityManager.datastoreToJava(bar); >>> >>> Save generating a primary key, with a parent instance: >>> FooBar bar = new FooBar(); >>> entityManager.put(parentKey, bar); >>> >>> More can be seen here:http://code.google.com/p/simpleds/wiki/SimpleTasks >>> >>> Any discussion about the current API state is welcome. This entire >>> thing was rolled in two days and tested in a couple of weeks so there >>> should be some bugs in between. >>> >>> It is important to keep in mind the current list of limitations: >>> >>> * Only the Key class is a supported primary key. >>> * IN and != are not supported (yet). I have big concerns about >>> supporting this, performance-wise. >>> * Relationships are not supported. You can use Keys and collections of >>> Keys for that purpose. >>> * Transactions are not yet included. We are not yet sure about how to >>> proceed here. >>> >>> As I said, this is not conceived to become a feature-complete JPA >>> replacement, so please don't treat it like that. >>> >>> Best regards, >>> >>> Nacho. >> >> >> > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Google App Engine for Java" 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-java?hl=en -~----------~----~----~----~------~----~------~--~---
