Hi MG, Sharded counters help solve the concurrent write contention for an entity. Time (to the accuracy of milliseconds) helps to provide a one way arrow towards a unique value. Each request itself could be associated with an identity (this is up to you, perhaps time in the request header). The combination of all 3 may lead to a guaranteed unique number.
Cheers, Nichole (p.s. If you do use sharded counters in your approach, you can configure the datastore read consistency to be strong: http://code.google.com/appengine/docs/java/datastore/usingjdo.html) On Dec 28, 8:33 pm, MG <michael.glas...@gmail.com> wrote: > Yes, keys are unique, but they are strings, and quite long (20+ > characters, from what I've seen). I do need unique and "growing" > numeric counter. > > On Dec 28, 11:20 pm, nischalshetty <nischalshett...@gmail.com> wrote: > > > > > > > > > Have a look at the Datastore "Key" thingy. The keys generated are > > unique across the system IMO. Not sure though but that's what I > > remember reading somewhere. > > > -N > > > On Dec 29, 7:43 am, MG <michael.glas...@gmail.com> wrote: > > > > Hello! > > > > I need to create a global atomic counter (64-bit) in my AppEngine/J > > > app. Like > > > > long count = MyCounter.increment() > > > > that will 100% guarantee that count will never ever be the same for > > > two different requests, and that I will be able to increment it > > > several million times/day initially, and much more if/when traffic > > > increases. I do not really care if it skips a number or two > > > occasionally: I can live with it returning a value larger than the > > > actual number of calls, but I do need absolute uniqueness and > > > reasonably linear growth (i.e. is two consecutive calls from a client > > > should result in ascending counter values). > > > > Is this possible to do with Google AppEngine? Sharded counters can > > > ensure consistent counting, but not unique counts; memcache counters > > > can ensure unique increments, but they are perishable and thus > > > difficult (impossible?) to properly synchronize with persistent > > > storage. Using one entity to read-update in a transaction will not > > > scale... > > > > Thanks, > > > 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 google-appengine-j...@googlegroups.com. To unsubscribe from this group, send email to google-appengine-java+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-appengine-java?hl=en.