I was seeing your link. You have used Objectify. Objectify already provides Monotonic helper class.
-Aswath www.accountingguru.in On Sat, Jan 1, 2011 at 12:57 AM, MG <[email protected]> wrote: > OK, so here is our solution: http://bit.ly/ec3Yyw > > The main idea: we are combining Datastore sharding counters with atomic > counters in Memcache to implement sequences. Our Sequence class has one > (overloaded) static method: long Sequence.next(String sSequenceName). The > method itself performs three simple steps: > > Step 1. Increment both the datastore counter (sharding) and the memcache > counter (atomic), if the latter is present. If it is, return its new value. > This step is scalable. > > Step 2. If the memcache counter is not present, “serially” synchronize it > with the datastore counter. This step can be viewed as an analog of > lock(Sequence); > synchronize counters; unlock(Sequence); > > Step 3. Repeat step 1. > > > Our resulting sequence is "growing" and unique because: > > 1. The value of the DB counter is always equal to, or larger, than the > value of the memcache counter, because the DB (sharding) counter is always > incremented before the memcache counter. > 2. We return only atomic increments of the memcache counter. > 3. When the memcache counter is initialized, it is set to a value that > is greater than any possible previous memcache value. > > Full source code is available here: http://bit.ly/ec3Yyw > > Any feedback? > > > MG > > -- > 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]<google-appengine-java%[email protected]> > . > For more options, visit this group at > http://groups.google.com/group/google-appengine-java?hl=en. > -- 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.
